[Checkins] SVN: ZODB/trunk/src/ When packing file storages with blobs, don't hold the commit lock

Jim Fulton jim at zope.com
Sun Aug 23 09:04:33 EDT 2009


Log message for revision 103106:
  When packing file storages with blobs, don't hold the commit lock
  while cleaning up removed blob files.
  
  Also refactored the code slightly for clarity.
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/FileStorage/FileStorage.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2009-08-23 12:44:11 UTC (rev 103105)
+++ ZODB/trunk/src/CHANGES.txt	2009-08-23 13:04:32 UTC (rev 103106)
@@ -14,6 +14,9 @@
 - Officially deprecated PersistentDict
   (https://bugs.launchpad.net/zodb/+bug/400775)
 
+- Small optimization of packing file storages with blobs.
+
+
 3.9.0b5 (2009-08-06)
 ====================
 

Modified: ZODB/trunk/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/FileStorage.py	2009-08-23 12:44:11 UTC (rev 103105)
+++ ZODB/trunk/src/ZODB/FileStorage/FileStorage.py	2009-08-23 13:04:32 UTC (rev 103106)
@@ -1148,7 +1148,9 @@
                 self._save_index()
 
                 if self.blob_dir:
-                    self._move_unpacked_blobs()
+                    self._commit_lock_release()
+                    have_commit_lock = False
+                    self._remove_blob_files_tagged_for_removal_during_pack()
             finally:
                 self._lock_release()
         finally:
@@ -1158,9 +1160,8 @@
             self._pack_is_in_progress = False
             self._lock_release()
 
-    def _move_unpacked_blobs(self):
-        # Move any blobs linked or copied while packing to the
-        # pack dir, which will become the old dir
+
+    def _remove_blob_files_tagged_for_removal_during_pack(self):
         lblob_dir = len(self.blob_dir)
         fshelper = self.fshelper
         old = self.blob_dir+'.old'
@@ -1181,10 +1182,11 @@
             link_or_copy(os.path.join(self.blob_dir, '.layout'),
                          os.path.join(old, '.layout'))
             def handle_file(path):
-                dest = os.path.dirname(old+path[lblob_dir:])
+                newpath = old+path[lblob_dir:]
+                dest = os.path.dirname(newpath)
                 if not os.path.exists(dest):
                     os.makedirs(dest, 0700)
-                os.rename(path, old+path[lblob_dir:])
+                os.rename(path, newpath)
             handle_dir = handle_file
         else:
             # Helpers that remove an oid dir or revision file.



More information about the Checkins mailing list