Open shamrin opened 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
It seems to me (after reading
shmig
source code), it's not safe to run multipleshmig up
commands at the same time. It could happen in real life if one tries to doshmig 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
:BEGIN
SELECT FROM $SCHEMA_TABLE FOR UPDATE WHERE version=$VERSION
ROLLBACK
if it fails and stop)INSERT INTO $SCHEMA_TABLE(version) VALUES ($VERSION)
COMMIT
@mbucc Would you be open to have this problem fixed in
shmig
? I could try to contribute the solution.