[Zodb-checkins] CVS: Zope3/src/zodb/storage - bdbminimal.py:1.20

Barry Warsaw barry at zope.com
Thu Jun 26 15:01:03 EDT 2003


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv17338

Modified Files:
	bdbminimal.py 
Log Message:
_dostore(): Disable attempts at conflict resolution because minimal
storage doesn't implement loadSerial() on which conflict resolution
depends.

pack(): Fixes for race conditions on the packmark, which caused two
bugs seen by Windows users <wink>.  We need to acquire the commit lock
before we clear out the packmark so that packing cannot start in the
middle of a transaction.  Otherwise, we'd clear the packmark table and
objects that have been written in the current transaction but not yet
linked to the root could have gotten garbage collected.


=== Zope3/src/zodb/storage/bdbminimal.py 1.19 => 1.20 ===
--- Zope3/src/zodb/storage/bdbminimal.py:1.19	Fri Jun  6 11:24:20 2003
+++ Zope3/src/zodb/storage/bdbminimal.py	Thu Jun 26 14:01:01 2003
@@ -19,7 +19,7 @@
 
 from zope.interface import implements
 
-from zodb.interfaces import ZERO
+from zodb.interfaces import ZERO, ConflictError
 from zodb.storage.interfaces import *
 from zodb.utils import p64, u64
 from zodb.conflict import ResolvedSerial
@@ -233,7 +233,7 @@
         newdeltas = {}
         for oid, delta in deltas.items():
             refcount = u64(self._refcounts.get(oid, ZERO, txn=txn)) + delta
-            assert refcount >= 0
+            assert refcount >= 0, refcount
             if refcount == 0:
                 # The reference count for this object has just gone to zero,
                 # so we can safely remove all traces of it from the serials,
@@ -269,14 +269,11 @@
             txn.commit()
 
     def _dostore(self, txn, oid, serial, data, refs):
-        conflictresolved = False
         oserial = self._getCurrentSerial(oid)
         if oserial is not None and serial <> oserial:
-            # The object exists in the database, but the serial number
-            # given in the call is not the same as the last stored serial
-            # number.  Raise a ConflictError.
-            data = self._conflict.resolve(oid, oserial, serial, data)
-            conflictresolved = True
+            # Conflict resolution depends on loadSerial() which minimal
+            # storage doesn't implement, so we can't do it.
+            raise ConflictError
         # Optimistically write to the various tables.
         newserial = self._serial
         revid = oid+newserial
@@ -293,9 +290,6 @@
         # stored between the mark and sweep would get collected away.
         if self._packing:
             self._packmark.put(oid, PRESENT, txn=txn)
-        # Return the new serial number for the object
-        if conflictresolved:
-            return ResolvedSerial
         return newserial
 
     def store(self, oid, serial, data, refs, version, transaction):
@@ -390,10 +384,15 @@
         # Before setting the packing flag to true, acquire the storage lock
         # and clear out the packmark table, in case there's any cruft left
         # over from the previous pack.
-        def clear_packmark(txn):
-            self._packmark.truncate(txn=txn)
-        self._withlock(self._withtxn, clear_packmark)
-        self._packing = True
+        self._commit_lock_acquire()
+        try:
+            # We have to do this within a Berkeley transaction
+            def clear_packmark(txn):
+                self._packmark.truncate(txn=txn)
+            self._withtxn(clear_packmark)
+            self._packing = True
+        finally:
+            self._commit_lock_release()
         try:
             # We don't wrap this in _withtxn() because we're going to do the
             # operation across several Berkeley transactions, which allows




More information about the Zodb-checkins mailing list