[llvm-commits] [LNT] r169650 - /lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py

Michael Gottesman mgottesman at apple.com
Fri Dec 7 15:10:00 PST 2012


Author: mgottesman
Date: Fri Dec  7 17:10:00 2012
New Revision: 169650

URL: http://llvm.org/viewvc/llvm-project?rev=169650&view=rev
Log:
[fieldchange] This patch fixes a deadlock issue when updating the database from version 2 to 3 in Postgres.

The specific error that occurs is that before we add the fieldchange
table, we perform some table lookup operations which create
transactions in the postgresql database. Then we attempt to create the
fieldchange table which attempts to modify said table. The end result
is that the lookup operation is waiting for a close transaction
message from the webapp, which is waiting for the create fieldchange
table transaction to finish. Thus we perform a commit before we do the
table creation operation in order to ensure that all previous
transactions end.

Modified:
    lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py

Modified: lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py?rev=169650&r1=169649&r2=169650&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py (original)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_2_to_3.py Fri Dec  7 17:10:00 2012
@@ -49,8 +49,15 @@
     # Add FieldChange to the test suite.
     Base = add_fieldchange(test_suite)
 
-    # Create tables.
+    # Create tables. We commit now since databases like Postgres run
+    # into deadlocking issues due to previous queries that we have run
+    # during the upgrade process. The commit closes all of the
+    # relevant transactions allowing us to then perform our upgrade.
+    session.commit()
     Base.metadata.create_all(engine)
+    # Commit changes (also closing all relevant transactions with
+    # respect to Postgres like databases).
+    session.commit()
 
 def upgrade(engine):
     # Create a session.
@@ -60,5 +67,3 @@
     upgrade_testsuite(engine, session, 'nts')
     upgrade_testsuite(engine, session, 'compile')
 
-    # Commit changes.
-    session.commit()





More information about the llvm-commits mailing list