← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stub/launchpad/trivial into lp:launchpad/devel

 

Stuart Bishop has proposed merging lp:~stub/launchpad/trivial into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #627741 oops-prune is aborting with a regex mismatch(?)
  https://bugs.launchpad.net/bugs/627741


Bug #636925 discusses test runs bombing out on ec2 runs.

This branch tweaks test_on_merge.py to emit information about rouge database connections so we can track them down.

This isn't a solution to Bug #636925 but it might help.
-- 
https://code.launchpad.net/~stub/launchpad/trivial/+merge/36853
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stub/launchpad/trivial into lp:launchpad/devel.
=== modified file 'test_on_merge.py'
--- test_on_merge.py	2010-09-23 23:54:27 +0000
+++ test_on_merge.py	2010-09-28 12:44:47 +0000
@@ -73,17 +73,28 @@
     except psycopg2.ProgrammingError, x:
         if 'does not exist' not in str(x):
             raise
-    cur.execute("""
-        select count(*) from pg_stat_activity
-        where datname in ('launchpad_dev',
-            'launchpad_ftest_template', 'launchpad_ftest')
-        """)
-    existing_connections = cur.fetchone()[0]
-    if existing_connections > 0:
-        print 'Cannot rebuild database. There are %d open connections.' % (
-                existing_connections,
-                )
+
+    # If there are existing database connections, terminate. We have
+    # rogue processes still connected to the database.
+    for loop in range(2):
+        cur.execute("""
+            SELECT usename, current_query
+            FROM pg_stat_activity
+            WHERE datname IN (
+                'launchpad_dev', 'launchpad_ftest_template', 'launchpad_ftest')
+            """)
+        results = list(cur.fetchall())
+        if not results:
+            break
+        # Rogue processes. Report, sleep for a bit, and try again.
+        for usename, current_query in results:
+            print '!! Open connection %s - %s' % (usename, current_query)
+        print 'Sleeping'
+        time.sleep(20)
+    else:
+        print 'Cannot rebuild database. There are open connections.'
         return 1
+
     cur.close()
     con.close()
 


Follow ups