Skip to content

Commit

Permalink
Commit transaction in migration
Browse files Browse the repository at this point in the history
Some databases (e.g., DB2) would deadlock on migration 16 because a
lock was held on the domain table for an uncommitted alter and then
SQLAlchemy queried the domain table info in a separate transaction.

The fix is to commit the ALTER statements to release the lock so
that the domain table schema query will not block.

I've run this with sqlite, mysql, and postgresql and they all worked.

Part of fix for bug 1188785

Change-Id: Ic540a6cb09a0c525df7aaea55b64af96f0dd87c7
  • Loading branch information
Brant Knudson committed Jun 7, 2013
1 parent 8398d2f commit 6715740
Showing 1 changed file with 2 additions and 0 deletions.
Expand Up @@ -347,6 +347,8 @@ def upgrade_user_table_with_col_create(meta, migrate_engine, session):
session.execute('ALTER TABLE "user" ADD CONSTRAINT user_dom_name_unique '
'UNIQUE (domain_id, name);')

session.commit()


def upgrade_project_table_with_col_create(meta, migrate_engine, session):
# Create the domain_id column. We want this to be not nullable
Expand Down

0 comments on commit 6715740

Please sign in to comment.