[Checkins] SVN: relstorage/trunk/ No need to hold the commit lock when cleaning out pack-specific tables.

Martijn Pieters mj at zopatista.com
Mon Feb 28 09:56:17 EST 2011


Log message for revision 120607:
  No need to hold the commit lock when cleaning out pack-specific tables.
  
  The object_ref and object_refs_added tables are only ever touched during packing, and we already hold a pack lock for that operation.

Changed:
  U   relstorage/trunk/CHANGES.txt
  U   relstorage/trunk/relstorage/adapters/packundo.py

-=-
Modified: relstorage/trunk/CHANGES.txt
===================================================================
--- relstorage/trunk/CHANGES.txt	2011-02-28 14:43:37 UTC (rev 120606)
+++ relstorage/trunk/CHANGES.txt	2011-02-28 14:56:17 UTC (rev 120607)
@@ -17,6 +17,10 @@
   This makes the packing process faster while at the same time yielding to
   regular ZODB commits when busy.
 
+- Do not hold the commit lock during pack cleanup while deleting rows from
+  the object reference tables; these tables are pack-specific and regular
+  ZODB commits never touch these.
+
 1.5.0b1 (2011-02-05)
 --------------------
 

Modified: relstorage/trunk/relstorage/adapters/packundo.py
===================================================================
--- relstorage/trunk/relstorage/adapters/packundo.py	2011-02-28 14:43:37 UTC (rev 120606)
+++ relstorage/trunk/relstorage/adapters/packundo.py	2011-02-28 14:56:17 UTC (rev 120607)
@@ -761,13 +761,18 @@
         # commit the work done so far
         conn.commit()
         self.locker.release_commit_lock(cursor)
-        self.locker.hold_commit_lock(cursor)
         log.info("pack: cleaning up")
 
+        # This section does not need to hold the commit lock, as it only
+        # touches pack-specific tables. We already hold a pack lock for that.
         log.debug("pack: removing unused object references")
         stmt = self._script_pack_object_ref
         self.runner.run_script(cursor, stmt)
 
+        # Do we need to hold the commit lock for this section? RelStorage
+        # normally ignores transactions where packed = TRUE. We hold the
+        # commit lock during packing to set the packed flag already.
+        self.locker.hold_commit_lock(cursor)
         log.debug("pack: removing empty packed transactions")
         stmt = """
         DELETE FROM transaction
@@ -1160,9 +1165,10 @@
         # commit the work done so far
         conn.commit()
         self.locker.release_commit_lock(cursor)
-        self.locker.hold_commit_lock(cursor)
         log.info("pack: cleaning up")
 
+        # This section does not need to hold the commit lock, as it only
+        # touches pack-specific tables. We already hold a pack lock for that.
         stmt = """
         DELETE FROM object_refs_added
         WHERE zoid IN (



More information about the checkins mailing list