[Zodb-checkins] CVS: ZODB4/src/zodb/storage/file - main.py:1.8

Jeremy Hylton jeremy at zope.com
Tue Jun 24 17:08:21 EDT 2003


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

Modified Files:
	main.py 
Log Message:
Change the _packt variable into two: _packing and _pack_time.


=== ZODB4/src/zodb/storage/file/main.py 1.7 => 1.8 ===
--- ZODB4/src/zodb/storage/file/main.py:1.7	Thu Jun 19 17:41:09 2003
+++ ZODB4/src/zodb/storage/file/main.py	Tue Jun 24 16:08:20 2003
@@ -67,9 +67,6 @@
         self._file = afile
 
 class FileStorage(BaseStorage, DataCopier):
-    # default pack time is 0
-    _packt = ZERO
-
     implements(IStorage, IUndoStorage, IVersionStorage)
 
     def __init__(self, file_name, create=0, read_only=0, stop=None,
@@ -140,6 +137,12 @@
                 self._index, self._vindex, self._tindex, stop,
                 read_only=read_only)
         self._ltid = tid
+        # The packing boolean is used by undo to prevent undo during
+        # a pack.  The _pack_time variable is set to a timestamp during
+        # a pack so that undoLog() / undoInfo() don't return txns
+        # that occurred during the pack time.
+        self._packing = False
+        self._pack_time = None
 
         # self._pos should always point just past the last
         # transaction.  During 2PC, data is written after _pos.
@@ -712,9 +715,9 @@
             last = first - last + 1
         self._lock_acquire()
         try:
-            if self._packt is None:
+            if self._packing:
                 raise UndoError("Can't undo during pack")
-            us = UndoSearch(self._file, self._pos, self._packt,
+            us = UndoSearch(self._file, self._pos, self._pack_time,
                             first, last, filter)
             while not us.finished():
                 # Hold lock for batches of 20 searches, so default search
@@ -875,13 +878,11 @@
         # Record pack time so we don't undo while packing
         self._lock_acquire()
         try:
-            # XXX _packt should just be a flag
-            if self._packt != ZERO:
+            if self._packing:
                 # Already packing.
                 raise FileStorageError("Already packing")
-            # when undo sees _packt == None, it raises an error that
-            # says "can't undo during pack"
-            self._packt = None
+            self._packing = True
+            self._pack_time = stop
         finally:
             self._lock_release()
 
@@ -918,7 +919,8 @@
             if p.locked:
                 self._commit_lock_release()
             self._lock_acquire()
-            self._packt = ZERO
+            self._packing = False
+            self._pack_time = None
             self._lock_release()
 
 




More information about the Zodb-checkins mailing list