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