mbucc / shmig

Database migration tool written in BASH.
BSD 3-Clause "New" or "Revised" License
461 stars 50 forks source link

Multiple `shmig up` commands running at the same time #58

Open shamrin opened 5 years ago

shamrin commented 5 years ago

It seems to me (after reading shmig source code), it's not safe to run multiple shmig up commands at the same time. It could happen in real life if one tries to do shmig up as part of application instance startup. With multiple instances of those running.

This problem is discussed at stackexchange.com, with a potential solution using SELECT FROM ... FOR UPDATE:

@mbucc Would you be open to have this problem fixed in shmig? I could try to contribute the solution.

mbucc commented 5 years ago

Hi,

This would be a valuable fix.

From a quick google, it looks like mysql and postgresql support "select for update"; sqlite3 does not. But I think it is fine to implement for whatever database you are using; I would certainly accept such a pull request.

I would like to add a test to shmig_test to verify bug before fixing it; I'll try and work one up this weekend.

Thanks,

Mark