Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ezdb - A one click script to quickly setting up a development database #75053

Merged
merged 7 commits into from May 15, 2023

Conversation

Mothblocks
Copy link
Member

@Mothblocks Mothblocks commented Apr 30, 2023

DiscordPTB_2023-04-30T02-00-28.mp4
  • Downloads a portable MariaDB (doesn't pollute your main system)
  • Sets up a database with a random password on port 1338 (configurable)
  • Installs the initial schema
  • Every time after, will run updates

Major versions right now explicitly escape hatch, because those historically come with something like a Python script, and I do not want it to pretend to work.

@tgstation-server tgstation-server added Tools We pretend to be a real development community Config Update Time to bother the headadmins for three months to get your config applied SQL Structured query language? more like Sanity Quality Loss GitHub Remember that time they had to get us to send them a copy of the repo labels Apr 30, 2023
@Mothblocks
Copy link
Member Author

Can a noob clone my branch and tell me if it works for them

@Jordie0608
Copy link
Member

Jordie0608 commented Apr 30, 2023

I've only had a cursory look through this but very neat.

Some suggestions:
Rather than merely warning about major version changes would it be possible to mark a change as needing extra steps for if say I have a change which requires extra steps but don't think it needs to be a major version change?

You should say in EZDB.md that python is required.

In update_schema.py It looks like if someone hasn't updated in quite a while it'd be possible for them to be a major version behind but have the latest minor version exceed what they have and thus run updates which might not work, i.e. v5.3 updating to v6.7. Maybe so long as this doesn't handle major version changes it'd be better to stop there rather than continuing onto minor changes?

It's not necessary but perhaps some handling for if the database's version is higher than the latest code version, I know this won't occur without someone messing around but it's happened to tg before so something like "you've messed up your versioning go fix that first".

@Mothblocks
Copy link
Member Author

In update_schema.py It looks like if someone hasn't updated in quite a while it'd be possible for them to be a major version behind but have the latest minor version exceed what they have and thus run updates which might not work, i.e. v5.3 updating to v6.7. Maybe so long as this doesn't handle major version changes it'd be better to stop there rather than continuing onto minor changes?

It shouldn't be, it continues when that happens

@Jordie0608
Copy link
Member

Er yes, apparently i'd forgotten how continue works

@san7890
Copy link
Member

san7890 commented May 3, 2023

i have skill of noob when it comes to DB stuff but i tested it out:

The first round, a CMD prompt came up and I instinctually closed it out because it was capturing my keyboard inputs and because I didn't know what it was for:

image

I didn't realize this was an issue until I did some more testing, and realized that the CMD prompt that I was getting was somehow critical to the functioning of ezdb - since I kept getting this runtime error whenever I closed out of that CMD prompt.

[2023-05-03 00:27:38.884] Running /tg/ revision: 2023-04-30
 - origin/master: fb60c65619b8f746a1d8a8761f37ef9f48ef2ef4
 - HEAD: 128f5057311f3f66af4759c1de29a53cd0f87e52
[2023-05-03 00:27:41.124] runtime error: Failed to start DB daemon: -1.07374e+009
 -  (code/controllers/subsystem/dbcore.dm:467)
 - proc name:  stack trace (/proc/_stack_trace)
 -   source file: stack_trace.dm,4
 -   usr: (src)
 -   src: null
 -   call stack:
 -  stack trace("Failed to start DB daemon: -1....", "code/controllers/subsystem/dbc...", 467)
 - Database (/datum/controller/subsystem/dbcore): start db daemon()

In fact, closing out the CMD prompt at any time during the server's runtime (which is what some users might do either by accident or because they don't know why it's there) completely yonks the SQL operations with the following error:

[2023-05-03 00:41:20.443] SQL: DriverError { Could not connect to address `localhost:1338': No connection could be made because the target machine actively refused it. (os error 10061) } | Query used: 
 - 			SELECT
 - 				type,
 - 				secret,
 - 				id,
 - 				IFNULL((SELECT byond_key FROM player WHERE ckey = adminckey), adminckey),
 - 				text,
 - 				timestamp,
 - 				server,
 - 				IFNULL((SELECT byond_key FROM player WHERE ckey = lasteditor), lasteditor),
 - 				DATEDIFF(NOW(), timestamp),
 - 				IFNULL((SELECT byond_key FROM player WHERE ckey = targetckey), targetckey),
 - 				expire_timestamp,
 - 				severity,
 - 				playtime,
 - 				round_id
 - 			FROM messages
 - 			WHERE type <> 'memo' AND targetckey = :targetckey AND deleted = 0 AND (expire_timestamp > NOW() OR expire_timestamp IS NULL)
 - 			ORDER BY timestamp DESC
 - 		 | Arguments: {"targetckey":"san7890"}

I don't know if you get the same visible CMD prompt like I have been, but it seems to work fine on my machine other than that slight hiccup.

image

@san7890
Copy link
Member

san7890 commented May 3, 2023

i also kept getting this error whenever i was trying to add a note (is it a localhost thing?) but i think that's less ezdb's problem and more a problem on master (unless this doesn't happen for some reason with real databases), just noting it down now because it might cause issues with that aspect of testing adminny code

[2023-05-03 00:39:27.662] SQL: MySqlError { ERROR 1048 (23000): Column 'ip' cannot be null } | Query used: 
 - 			INSERT INTO player (`ckey`, `byond_key`, `firstseen`, `firstseen_round_id`, `lastseen`, `lastseen_round_id`, `ip`, `computerid`, `lastadminrank`, `accountjoindate`)
 - 			VALUES (:ckey, :key, Now(), :round_id, Now(), :round_id, INET_ATON(:ip), :computerid, :adminrank, :account_join_date)
 - 		 | Arguments: {"ckey":"san7890","key":"San7890","round_id":"5","ip":null,"computerid":"{CENSORED}","adminrank":"Game Master","account_join_date":null}

resending this since i accidentally sent my CID whoops

@Mothblocks Mothblocks marked this pull request as draft May 3, 2023 15:51
@Mothblocks
Copy link
Member Author

A command prompt really shouldn't be opening, and it's not for me. It's a daemon. I will look into it I suppose? Also yes that looks like a master bug.

@Mothblocks
Copy link
Member Author

Still going to look into that just tired

@Mothblocks
Copy link
Member Author

Yeah I don't get that at all =( I have no idea what to do about that

@Mothblocks Mothblocks marked this pull request as ready for review May 7, 2023 18:31
@Mothblocks
Copy link
Member Author

mso gave me an ok enough idea to lean into the command bar so why not

@Mothblocks Mothblocks marked this pull request as draft May 8, 2023 07:13
@Mothblocks Mothblocks marked this pull request as ready for review May 14, 2023 22:57
@Mothblocks
Copy link
Member Author

@san7890 Can you use the latest build? It doesn't fix the command prompt issue (I don't know why that happens or how to stop it) but tell me if you see the echo message that it gives you

Copy link
Member

@san7890 san7890 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, python was so snail-crawl speed at doing the url retrieve step of the install (I don't even know if it was working or not) but I just did some schenanigans and beyond that it worked fine (this is probably an issue with my machine and might not apply to the community at large)

however, for some odd reason it was just flashing the CMD prompt and auto-closing, and I was getting this runtime posting to config_error.log. doing the debugger showed that it was crashing out at the shelleo call for whatever reason

[2023-05-15 02:53:25.382] SQL: Connect() failed | DriverError { Could not connect to address `localhost:1338': No connection could be made because the target machine actively refused it. (os error 10061) }
[2023-05-15 02:53:25.383] SQL: Your server failed to establish a connection with the database.
[2023-05-15 02:53:29.457] SQL: Connect() failed | DriverError { Could not connect to address `localhost:1338': No connection could be made because the target machine actively refused it. (os error 10061) }

HOWEVER, I was able to get it to work the way that one would expect by changing the shelleo to the suggestion enclosed with this review.

image
The shell message is different because I just wrote it from what it should be, and everything seems to be working as expected.

BTW, I figured out a surefire way to have the daemon show up (at least for me), and that's just running the same exe you get in the DB_DAEMON portion of the ezdb.txt config file. That's what got it to show up for me outside of the game context, not sure if that would work for you though.

code/controllers/subsystem/dbcore.dm Outdated Show resolved Hide resolved
@Mothblocks
Copy link
Member Author

Well yeah if you run it directly but I can't do anything about that

Co-authored-by: san7890 <the@san7890.com>
@san7890 san7890 merged commit 980f3ad into tgstation:master May 15, 2023
18 checks passed
Jolly-66 added a commit to TaleStation/TaleStation that referenced this pull request May 28, 2023
…elopment database (#5979)

Original PR: tgstation/tgstation#75053
---

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
Absolucy pushed a commit to Absolucy/Monkestation that referenced this pull request Mar 9, 2024
tgstation#75053)

https://user-images.githubusercontent.com/35135081/235344815-8e825ba9-52cf-44e8-b8e2-a2aeb5d47276.mp4

- Downloads a portable MariaDB (doesn't pollute your main system)
- Sets up a database with a random password on port 1338 (configurable)
- Installs the initial schema
- Every time after, will run updates

Major versions right now explicitly escape hatch, because those
historically come with something like a Python script, and I do not want
it to pretend to work.

---------

Co-authored-by: san7890 <the@san7890.com>
dwasint pushed a commit to Monkestation/Monkestation2.0 that referenced this pull request Mar 10, 2024
…database (#1366)

* ezdb - A one click script to quickly setting up a development database (tgstation#75053)

https://user-images.githubusercontent.com/35135081/235344815-8e825ba9-52cf-44e8-b8e2-a2aeb5d47276.mp4

- Downloads a portable MariaDB (doesn't pollute your main system)
- Sets up a database with a random password on port 1338 (configurable)
- Installs the initial schema
- Every time after, will run updates

Major versions right now explicitly escape hatch, because those
historically come with something like a Python script, and I do not want
it to pretend to work.

---------

Co-authored-by: san7890 <the@san7890.com>

* Comment out /tg/ contributors from CODEOWNERS

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Config Update Time to bother the headadmins for three months to get your config applied GitHub Remember that time they had to get us to send them a copy of the repo SQL Structured query language? more like Sanity Quality Loss Tools We pretend to be a real development community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants