You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the Bug
When starting a migration job while another migration is still running, the new migration job keeps waiting on the first job and never times out.
Steps to Reproduce
Create a long running (60 seconds in this case) migration job.
Filename 0001_initialize_schema.up.sql
Contents
SELECT pg_sleep(60);
Start the long running migration job
$ migrate -source file://<path-to-migration-file> -database postgres://postgres:postgres@localhost/postgres up
In another shell, start the same migration job (while the first one is still running).
$ migrate -source file://<path-to-migration-file> -database postgres://postgres:postgres@localhost/postgres up
Expected Behavior
The first job finishes in 60 seconds (according to the sleep in migration file). The second job fails after 15 seconds (this is the default value for -lock-timeout).
Migrate Version
v4.5.0, installed using Brew.
Obtained by running: migrate -version
Loaded Source Drivers
e.g. file
Obtained by running: migrate -help
Loaded Database Drivers
postgres
Obtained by running: migrate -help
Go Version
go version go1.12.5 darwin/amd64
Obtained by running: go version
Stacktrace
Not applicable.
Additional context
The timeout logic inside migrate.go:
I think adding context won't help. I just had the issue that a query got stuck for hours. After restarting all instances of the service, I ended up with multiple SELECT pg_advisory_lock($1) stuck in the background, all waiting for a lock even though the services which initiated those queries weren't even running anymore. If the service goes offline before the context is canceled then the lock will never be released, and attempts to obtain a lock will hang forever.
Is there any particular reason why we couldn't run the migrations within a transaction and set the lock timeout within the transaction?
Uh oh!
There was an error while loading. Please reload this page.
Note: written together with @hugoboos
Describe the Bug
When starting a migration job while another migration is still running, the new migration job keeps waiting on the first job and never times out.
Steps to Reproduce
Filename
0001_initialize_schema.up.sql
Contents
Expected Behavior
The first job finishes in 60 seconds (according to the sleep in migration file). The second job fails after 15 seconds (this is the default value for
-lock-timeout
).Migrate Version
v4.5.0, installed using Brew.
Obtained by running:
migrate -version
Loaded Source Drivers
e.g. file
Obtained by running:
migrate -help
Loaded Database Drivers
postgres
Obtained by running:
migrate -help
Go Version
go version go1.12.5 darwin/amd64
Obtained by running:
go version
Stacktrace
Not applicable.
Additional context
The timeout logic inside
migrate.go
:migrate/migrate.go
Line 885 in b071731
postgres.go
:migrate/database/postgres/postgres.go
Line 101 in 6c96ef0
We suggest to implement the timeout logic inside the
Lock
method of the database driver. Eg. for Postgres that would be insidepostgres.go
:migrate/database/postgres/postgres.go
Line 143 in 6c96ef0
The text was updated successfully, but these errors were encountered: