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

Question: concurrency #464

Closed
germanSancho opened this issue Feb 21, 2017 · 8 comments
Closed

Question: concurrency #464

germanSancho opened this issue Feb 21, 2017 · 8 comments
Labels

Comments

@germanSancho
Copy link

germanSancho commented Feb 21, 2017

Hello,

First of all, thanks for this great library!

I have a concern about how concurrency is handled when executing migrations. What happens if several people (or several scripts) try to run a db-migrate up at the same time against the same database? Is there any locking mechanism?

This is my usecase: I want to add db-migrate up as part of my deployment workflow (inside my npm run script) so when I deploy a new version of my app in an environment, new migrations are executed automatically. In environments like heroku, kubernetes and the like, several instances can be started concurrently, so the migration scripts can be launched concurrently. Without a locking mechanism, this can result on the same migrations being executed several times, etc.

I know that in Liquibase, for example, uses a separate "lock" table to prevent this kind of problems (see http://www.liquibase.org/documentation/databasechangeloglock_table.html).

I seems to me that there is no equivalent mechanism in db-migrate currently. Am I mistaken? If not, are there any plans for implementing it in the future?

Thanks!


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@wzrdtales
Copy link
Member

What happens if several people (or several scripts) try to run a db-migrate up at the same time against the same database? Is there any locking mechanism?

Depending on what they going to execute some of them just die while the process is running or if you do something strange in your up or down routine even worse things could happen which could leave you in a broken state.

I actually have been asked this some time ago and yes, I am definitely going to add some locking mechanism, which will be especially important for zero downtime stuff.

@germanSancho
Copy link
Author

Great. Let me know if you need some testing and/or help with the design :)

@fdw
Copy link

fdw commented Oct 17, 2017

Has there been any progress with this? I'd like to use this feature as well.

@wzrdtales
Copy link
Member

@fdw Not yet, work is starting to get traction on some items currently, also looking at this item again right now.

@wzrdtales wzrdtales mentioned this issue Feb 3, 2018
4 tasks
@wzrdtales
Copy link
Member

State manager is in work currently, which will cover this topic as well as some other topics such as atomic actions, crash resistent migrations and ZDC.

@1MikeMakuch
Copy link

Has there been any progress with this? I'd like to use this feature as well.

@wzrdtales
Copy link
Member

Yes, some progress, in the beta version there is already the state manager, but it does not yet take care of concurrency control.

@wzrdtales
Copy link
Member

tracked in #538

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

No branches or pull requests

4 participants