[Zope3-checkins] CVS: ZODB4/src/zodb/storage/file - pack.py:1.7

Jeremy Hylton jeremy@zope.com
Fri, 16 May 2003 15:44:42 -0400


Update of /cvs-repository/ZODB4/src/zodb/storage/file
In directory cvs.zope.org:/tmp/cvs-serv3075/storage/file

Modified Files:
	pack.py 
Log Message:
Periodically release the commit lock while packing.


=== ZODB4/src/zodb/storage/file/pack.py 1.6 => 1.7 ===
--- ZODB4/src/zodb/storage/file/pack.py:1.6	Thu May 15 17:00:54 2003
+++ ZODB4/src/zodb/storage/file/pack.py	Fri May 16 15:44:42 2003
@@ -441,9 +441,8 @@
         # After the pack time, all data records are copied.
         # Copy one txn at a time, using copy() for data.
 
-        # XXX Release the lock every N txns to let someone
-        # waiting to write a new txn have a go.
-
+        # Release the commit lock every 20 copies
+        self._lock_counter = 0
 
         try:
             while 1:
@@ -459,7 +458,11 @@
                 raise
 
     def copyOne(self, ipos):
+        # The call below will raise CorruptedDataError at EOF.
         th = self._read_txn_header(ipos)
+        self._lock_counter += 1
+        if self._lock_counter % 20 == 0:
+            self._commit_lock_release()
         pos = self._tfile.tell()
         self._copier.setTxnPos(pos)
         self._tfile.write(th.asString())
@@ -493,5 +496,7 @@
         self.tindex.clear()
         self.vindex.update(self.tvindex)
         self.tvindex.clear()
+        if self._lock_counter % 20 == 0:
+            self._commit_lock_acquire()
         return ipos