Skip to content

Dirty DB despite successful migration #325

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

Closed
chrismwendt opened this issue Jan 18, 2020 · 2 comments
Closed

Dirty DB despite successful migration #325

chrismwendt opened this issue Jan 18, 2020 · 2 comments
Labels
backwards incompatible Change is backwards incompatible duplicate This issue or pull request already exists

Comments

@chrismwendt
Copy link

chrismwendt commented Jan 18, 2020

Describe the Bug

When the migrate command is killed while a migration is running and the migration succeeds asynchronously inside Postgres, the DB is left marked dirty when in reality it's clean. This is inconsistent, and causes confusion.

This situation realistically occurs when a migration takes longer to run than the app is given to initialize by the supervisor (e.g. Kubernetes) and the supervisor restarts the app.

Steps to Reproduce

Full repro at https://github.com/chrismwendt/golang-migrate-consistency

Expected Behavior

For databases that support transactions/rollback (specifically Postgres), the DB should not be eagerly marked dirty until the migration has failed.

The DB should never be in a state where the migration succeeded but the DB has been marked dirty.

Migrate Version 4.8.0

Loaded Source Drivers file

Loaded Database Drivers postgres, postgresql, stub

Go Version go version go1.13.3 darwin/amd64

Stacktrace N/A

Discussion

Are there any existing issues related to this?

Does anyone have other ideas on how to enforce the consistency? This won't work for databases that don't support transactions, but perhaps it could be an optional feature that transactional database drivers support.

@chrismwendt
Copy link
Author

There's a prototype solution in #326

@dhui dhui added backwards incompatible Change is backwards incompatible duplicate This issue or pull request already exists labels Jan 20, 2020
@dhui
Copy link
Member

dhui commented Jan 20, 2020

Duplicate of #196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible Change is backwards incompatible duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants