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

Add lock for concurrent migrations running from several nodes #45

Closed
dskarataev opened this issue Nov 5, 2016 · 3 comments
Closed

Add lock for concurrent migrations running from several nodes #45

dskarataev opened this issue Nov 5, 2016 · 3 comments

Comments

@dskarataev
Copy link

dskarataev commented Nov 5, 2016

Hi,

could you please add a lock for migrations? Our API runs migrations right before initialization and it's running on more than one node, so we have conflicts because the migrations try to apply at the same time from different nodes. It's ok for CREATE IF NOT EXIST or ALTER but not so good for datafixes like simple INSERT new value.

Please consider to acquire access using GET LOCK or some similar approach, thanks.

http://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock

@Dynom
Copy link

Dynom commented Jan 2, 2017

I'm not sure if @rubenv is considering this, but I personally probably wouldn't merge it in sql-migrate.

I think that the problem you're describing is something you should solve on a different layer in your operations process. Either via the process management or deployment tools you use. Even with locking in place, this isn't non-trivial to add and frankly not part of the problem sql-migrate tries to solve.

sql-migrate is also a library, so it's probably quite doable to hack your own implementation for your specific MySQL use-case.

Just my two cents

@rubenv
Copy link
Owner

rubenv commented Jan 2, 2017

Yup, agreeing with @Dynom here. Let's keep sql-migrate simple.

@dselans
Copy link

dselans commented Feb 20, 2017

@dskarataev I had the same exact need and implemented such functionality in #58. I'm not sure if this is the direction that sql-migrate folks want to take it though, so we'll see.

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

4 participants