-
Notifications
You must be signed in to change notification settings - Fork 522
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
Timeout Flag #627
Timeout Flag #627
Conversation
@@ -99,6 +100,56 @@ func TestMigrateUpTo(t *testing.T) { | |||
check.Number(t, gotVersion, upToVersion) // incorrect database version | |||
} | |||
|
|||
func TestMigrateUpTimeout(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests are simulating the library timeout, but we should probably have something that exercises the --timeout
flag and uses pg_sleep
(sqlite would be ideal, but I don't think there's a way to do that in sqlite)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README.md
Outdated
@@ -105,6 +105,8 @@ Options: | |||
file path to SSL key in pem format (only supported on mysql) | |||
-table string | |||
migrations table name (default "goose_db_version") | |||
-timeout duration | |||
duration that the queries should run for; e.g. 1h13m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duration that the queries should run for; e.g. 1h13m | |
maximum duration queries allowed to run; e.g. 1h13m |
Not sure if that's better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with:
-timeout duration
maximum allowed duration for queries to run; e.g., 1h13m
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting that together, and apologies for delay in reviewing.
You mean something like this, right? Where timeout was set to 5s, but migration 2 had a
Same as the previous one, but in this case goose partially migrated before the timeout was reached? |
Note, this isn't really needed since the context outlives the main function. But go is being difficult despite adding nolint comment //nolint:govet // The context outlives the main function
All good! Glad I got a chance to contribute! |
Adds a CLI flag
-timeout
so that users can specify a duration for how long the migrations should be able to run.Closes #576
Some edge cases
NO TRANSACTION
the timeout wont be respected if it's been exceeded for that part of the migration.Let me know if I should change anything else.