db: INSERT IGNORE on schema_migrations to tolerate multi-worker boot race
This commit is contained in:
parent
48026aeae4
commit
00a4c71aa9
1 changed files with 3 additions and 1 deletions
|
|
@ -100,8 +100,10 @@ class DB:
|
||||||
if ver in done:
|
if ver in done:
|
||||||
continue
|
continue
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
|
# IGNORE to tolerate the multi-worker boot race where two
|
||||||
|
# gunicorn workers both bootstrap an empty migrations table
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"INSERT INTO schema_migrations (version) VALUES (%s)", (ver,)
|
"INSERT IGNORE INTO schema_migrations (version) VALUES (%s)", (ver,)
|
||||||
)
|
)
|
||||||
applied.append(ver)
|
applied.append(ver)
|
||||||
return applied
|
return applied
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue