Commit 81748109 authored by Jeremy Hylton's avatar Jeremy Hylton

Merge MVCC branch to the HEAD.

parent f72e57be
This diff is collapsed.
......@@ -15,7 +15,7 @@
"""Berkeley storage without undo or versioning.
"""
__version__ = '$Revision: 1.33 $'[-2:][0]
__version__ = '$Revision: 1.34 $'[-2:][0]
from ZODB import POSException
from ZODB.utils import p64, U64
......@@ -158,10 +158,10 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
self._pending.truncate(txn)
def _abort(self):
self._withtxn(self._doabort, self._serial)
self._withtxn(self._doabort, self._tid)
def _docommit(self, txn, tid):
self._pending.put(self._serial, COMMIT, txn)
self._pending.put(self._tid, COMMIT, txn)
deltas = {}
co = cs = None
try:
......@@ -248,7 +248,7 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
# will be aborted.
txn = self._env.txn_begin()
try:
self._pending.put(self._serial, ABORT, txn)
self._pending.put(self._tid, ABORT, txn)
except:
txn.abort()
raise
......@@ -271,7 +271,7 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
oid=oid, serials=(oserial, serial), data=data)
# Optimistically write to the serials and pickles table. Be sure
# to also update the oids table for this object too.
newserial = self._serial
newserial = self._tid
self._serials.put(oid, newserial, txn=txn)
self._pickles.put(oid+newserial, data, txn=txn)
self._oids.put(oid, PRESENT, txn=txn)
......@@ -305,7 +305,7 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
# _docommit() twiddles the pending flag to COMMIT now since after the
# vote call, we promise that the changes will be committed, no matter
# what. The recovery process will check this.
self._withtxn(self._docommit, self._serial)
self._withtxn(self._docommit, self._tid)
#
# Accessor interface
......@@ -340,7 +340,7 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
return None
if len(serials) == 1:
return serials[0]
pending = self._pending.get(self._serial)
pending = self._pending.get(self._tid)
assert pending in (ABORT, COMMIT)
if pending == ABORT:
return serials[0]
......@@ -363,7 +363,7 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
self._lock_release()
def modifiedInVersion(self, oid):
# So BaseStorage.getSerial() just works. Note that this storage
# So BaseStorage.getTid() just works. Note that this storage
# doesn't support versions.
return ''
......@@ -548,7 +548,7 @@ class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
# versionEmpty(self, version)
# versions(self, max=None)
# loadSerial(self, oid, serial)
# getSerial(self, oid)
# getTid(self, oid)
# transactionalUndo(self, tid, transaction)
# undoLog(self, first=0, last=-20, filter=None)
# history(self, oid, version=None, size=1, filter=None)
......
......@@ -29,20 +29,21 @@ DBHOME = 'test-db'
class BerkeleyTestBase(StorageTestBase):
def _config(self):
def _config(self, read_only=False):
# Checkpointing just slows the tests down because we have to wait for
# the thread to properly shutdown. This can take up to 10 seconds, so
# for the purposes of the test suite we shut off this thread.
config = BerkeleyConfig()
config.interval = 0
config.read_only = read_only
return config
def _envdir(self):
return DBHOME
def open(self):
def open(self, read_only=False):
self._storage = self.ConcreteStorage(
self._envdir(), config=self._config())
self._envdir(), config=self._config(read_only))
def _zap_dbhome(self, dir=None):
if dir is None:
......
......@@ -52,12 +52,13 @@ class C(Persistent):
class TestAutopackBase(BerkeleyTestBase):
def _config(self):
def _config(self, read_only=False):
config = BerkeleyConfig()
# Autopack every 1 second, 2 seconds into the past, no classic packs
config.frequency = 1
config.packtime = 2
config.gcpack = 0
config.read_only = read_only
return config
def _wait_for_next_autopack(self):
......@@ -114,13 +115,14 @@ class TestAutopack(TestAutopackBase):
class TestAutomaticClassicPack(TestAutopackBase):
ConcreteStorage = BDBFullStorage
def _config(self):
def _config(self, read_only=False):
config = BerkeleyConfig()
# Autopack every 1 second, 2 seconds into the past, classic packing
# every time.
config.frequency = 1
config.packtime = 2
config.gcpack = 1
config.read_only = read_only
return config
def testAutomaticClassicPack(self):
......@@ -196,10 +198,11 @@ class TestAutomaticClassicPack(TestAutopackBase):
class TestMinimalPack(TestAutopackBase):
ConcreteStorage = BDBMinimalStorage
def _config(self):
def _config(self, read_only=False):
config = BerkeleyConfig()
# Autopack every 3 seconds
config.frequency = 3
config.read_only = read_only
return config
def testRootUnreachable(self):
......
......@@ -21,20 +21,32 @@ import BDBStorage
from BDBStorage.tests import BerkeleyTestBase
from ZODB.tests.BasicStorage import BasicStorage
from ZODB.tests.HistoryStorage import HistoryStorage
from ZODB.tests.IteratorStorage import IteratorStorage, ExtendedIteratorStorage
from ZODB.tests.MTStorage import MTStorage
from ZODB.tests.PackableStorage import PackableStorage, PackableUndoStorage
from ZODB.tests.PersistentStorage import PersistentStorage
from ZODB.tests.ReadOnlyStorage import ReadOnlyStorage
from ZODB.tests.RecoveryStorage import RecoveryStorage
from ZODB.tests.RevisionStorage import RevisionStorage
from ZODB.tests.VersionStorage import VersionStorage
from ZODB.tests.Synchronization import SynchronizedStorage
from ZODB.tests.TransactionalUndoStorage import TransactionalUndoStorage
from ZODB.tests.TransactionalUndoVersionStorage import \
TransactionalUndoVersionStorage
from ZODB.tests.PackableStorage import PackableStorage
from ZODB.tests.HistoryStorage import HistoryStorage
from ZODB.tests.IteratorStorage import IteratorStorage, ExtendedIteratorStorage
from ZODB.tests.RecoveryStorage import RecoveryStorage
from ZODB.tests.VersionStorage import VersionStorage
from ZODB.tests import ConflictResolution
class MinimalTest(BerkeleyTestBase.MinimalTestBase, BasicStorage):
class MinimalTest(BerkeleyTestBase.MinimalTestBase,
BasicStorage,
MTStorage,
PackableStorage,
ReadOnlyStorage,
SynchronizedStorage,
):
def checkVersionedStoreAndLoad(self):
# This storage doesn't support versions, so we should get an exception
oid = self._storage.new_oid()
......@@ -47,11 +59,15 @@ class FullTest(BerkeleyTestBase.FullTestBase, BasicStorage,
RevisionStorage, VersionStorage,
TransactionalUndoStorage,
TransactionalUndoVersionStorage,
PackableStorage,
PackableStorage, PackableUndoStorage,
HistoryStorage,
IteratorStorage, ExtendedIteratorStorage,
ConflictResolution.ConflictResolvingStorage,
ConflictResolution.ConflictResolvingTransUndoStorage):
ConflictResolution.ConflictResolvingTransUndoStorage,
SynchronizedStorage,
PersistentStorage,
MTStorage,
ReadOnlyStorage):
pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment