[Zope3-checkins] CVS: ZODB4/src/zodb/storage - bdbfull.py:1.10
Barry Warsaw
barry@wooz.org
Fri, 24 Jan 2003 13:54:15 -0500
Update of /cvs-repository/ZODB4/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv7782
Modified Files:
bdbfull.py
Log Message:
_version_check(): Add a storage-level version string to the info
table. When opening the database, assert that it's either missing (in
which case, we add it), or it matches the known current value. Since
there's no previous version, raise a StorageSystemError if they
differ.
=== ZODB4/src/zodb/storage/bdbfull.py 1.9 => 1.10 ===
--- ZODB4/src/zodb/storage/bdbfull.py:1.9 Thu Jan 23 15:38:57 2003
+++ ZODB4/src/zodb/storage/bdbfull.py Fri Jan 24 13:54:12 2003
@@ -26,7 +26,7 @@
from zodb.serialize import findrefs
from zodb.timestamp import TimeStamp
from zodb.conflict import ConflictResolvingStorage, ResolvedSerial
-from zodb.interfaces import ITransactionAttrs
+from zodb.interfaces import ITransactionAttrs, StorageSystemError
from zodb.storage.base import db, ZERO, BerkeleyBase, PackStop, _WorkThread
from zodb.storage._helper import incr
@@ -34,6 +34,8 @@
COMMIT = 'C'
PRESENT = 'X'
+BDBFULL_SCHEMA_VERSION = 'BF01'
+
# Special flag for uncreated objects (i.e. Does Not Exist)
DNE = '\377'*8
# DEBUGGING
@@ -223,16 +225,13 @@
# Tables to support packing.
self._objrevs = self._setupDB('objrevs', db.DB_DUP)
self._delqueue = self._setupDB('delqueue', 0, db.DB_QUEUE, 8)
- # Do recovery and consistency checks
- self._withlock(self._dorecovery)
- def _make_autopacker(self, event):
- config = self._config
- lastpacktime = u64(self._last_packtime())
- return _Autopack(
- self, event,
- config.frequency, config.packtime, config.classicpack,
- lastpacktime)
+ def _version_check(self, txn):
+ version = self._info.get('version')
+ if version is None:
+ self._info.put('version', BDBFULL_SCHEMA_VERSION, txn=txn)
+ elif version <> BDBFULL_SCHEMA_VERSION:
+ raise StorageSystemError, 'incompatible storage version'
def _dorecovery(self):
# If these tables are non-empty, it means we crashed during a pack
@@ -287,6 +286,14 @@
self.__ltid = rec[0]
else:
self.__ltid = ZERO
+
+ def _make_autopacker(self, event):
+ config = self._config
+ lastpacktime = u64(self._last_packtime())
+ return _Autopack(
+ self, event,
+ config.frequency, config.packtime, config.classicpack,
+ lastpacktime)
def _doabort(self, txn, tid):
# First clean up the oid indexed (or oid+tid indexed) tables.