Skip to content

Commit

Permalink
protect the migration with advisory lock
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed May 16, 2019
1 parent 7879d2b commit fa01acd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions datamodelutils/postgres_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def _create_tables(driver, create_all, timeout):
logger.info('Creating tables (timeout: %d)', timeout)
with driver.session_scope() as session:
connection = session.connection()
connection.execute("SELECT pg_advisory_lock(%s)", hash(create_all) % 2 ** 63)
logger.info("Setting lock_timeout to %d", timeout)

timeout_str = '{}s'.format(int(timeout+1))
Expand Down

0 comments on commit fa01acd

Please sign in to comment.