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

DB driver operations should be atomic #151

Open
1 task
dhui opened this issue Jan 12, 2019 · 1 comment
Open
1 task

DB driver operations should be atomic #151

dhui opened this issue Jan 12, 2019 · 1 comment

Comments

@dhui
Copy link
Member

dhui commented Jan 12, 2019

Describe the Bug
Not all DB driver operations are atomic as show by #150

Operations that aren't locked:

  • Schema/version table management. e.g. all CRUD operations.

Steps to Reproduce
Creating multiple instances of a DB driver (which will attempt to create the schema/version table)
See test added in this PR: https://github.com/golang-migrate/migrate/pull/150/files#diff-5cc52c39a5031732bc6d3821ffc558e6

Expected Behavior
All DB driver operations should be atomic

Migrate Version
N/A

Loaded Source Drivers
N/A

Loaded Database Drivers
N/A

Go Version
N/A

Stacktrace
N/A

Additional context
The fix for all drivers might be complicated. Not all DB driver lock implementations are reentrant. Some DB drivers implement locks using other tables which complicates the fix.
It may be cleaner to expose schema/version table operations in the new DB driver interface and provide guidance on lock implementations.

@dhui
Copy link
Member Author

dhui commented Feb 21, 2019

Schema version table creation is locked in Postgres after this PR: #150
All other DBs will have their schema version table creation locked after this PR: #173

Locking schema version table creation created a bug when dropping: #164
#173 fixes the "dropping bug" but does so by not re-creating the schema version table. This has the side-effect where after calling database.Driver.Drop(), you'll need to recreate your database.Driver instance using database.Driver.Open(). If you're using a migrate.Migrate instance, that'll also need to be re-created after calling migrate.Migrate.Drop() for the same reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant