[Zodb-checkins] CVS: ZODB3/BDBStorage - BDBMinimalStorage.py:1.28

Barry Warsaw barry@wooz.org
Mon, 27 Jan 2003 16:08:16 -0500


Update of /cvs-repository/ZODB3/BDBStorage
In directory cvs.zope.org:/tmp/cvs-serv17621

Modified Files:
	BDBMinimalStorage.py 
Log Message:
_dostore(): Backport the second half of the pack related race condition fix.

_version_check(): Backport the setting up and checking of the storage
version string.


=== ZODB3/BDBStorage/BDBMinimalStorage.py 1.27 => 1.28 ===
--- ZODB3/BDBStorage/BDBMinimalStorage.py:1.27	Tue Jan 21 16:53:30 2003
+++ ZODB3/BDBStorage/BDBMinimalStorage.py	Mon Jan 27 16:08:13 2003
@@ -35,6 +35,8 @@
     True = 1
     False = 0
 
+BDBMINIMAL_SCHEMA_VERSION = 'BM01'
+
 
 
 class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
@@ -124,6 +126,13 @@
             finally:
                 self._lock_release()
 
+    def _version_check(self, txn):
+        version = self._info.get('version')
+        if version is None:
+            self._info.put('version', BDBMINIMAL_SCHEMA_VERSION, txn=txn)
+        elif version <> BDBMINIMAL_SCHEMA_VERSION:
+            raise StorageSystemError, 'incompatible storage version'
+
     def _make_autopacker(self, event):
         return _Autopack(self, event, self._config.frequency)
 
@@ -269,6 +278,12 @@
         self._serials.put(oid, newserial, txn=txn)
         self._pickles.put(oid+newserial, data, txn=txn)
         self._oids.put(oid, PRESENT, txn=txn)
+        # If we're in the middle of a pack, we need to add these objects to
+        # the packmark, so a specific race condition won't collect them.
+        # E.g. we do a mark, then we do a store, then we sweep.  The objects
+        # 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