Skip to content

Dirty DB despite successful migration #325

Closed
@chrismwendt

Description

@chrismwendt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backwards incompatibleChange is backwards incompatibleduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions