Commit 4d0512f1 authored by Julien Muchembled's avatar Julien Muchembled

Various fixes suggested in review

parent 7e1db13f
...@@ -73,6 +73,7 @@ class DemoStorage(ConflictResolvingStorage): ...@@ -73,6 +73,7 @@ class DemoStorage(ConflictResolvingStorage):
self._issued_oids = set() self._issued_oids = set()
self._stored_oids = set() self._stored_oids = set()
self._resolved = []
self._commit_lock = ZODB.utils.Lock() self._commit_lock = ZODB.utils.Lock()
self._transaction = None self._transaction = None
...@@ -116,7 +117,7 @@ class DemoStorage(ConflictResolvingStorage): ...@@ -116,7 +117,7 @@ class DemoStorage(ConflictResolvingStorage):
for meth in ( for meth in (
'_lock', '_lock',
'getSize', 'isReadOnly', 'getSize', 'isReadOnly',
'sortKey', 'tpc_transaction', 'tpc_vote', 'sortKey', 'tpc_transaction',
): ):
setattr(self, meth, getattr(changes, meth)) setattr(self, meth, getattr(changes, meth))
...@@ -308,7 +309,8 @@ class DemoStorage(ConflictResolvingStorage): ...@@ -308,7 +309,8 @@ class DemoStorage(ConflictResolvingStorage):
if old != serial: if old != serial:
rdata = self.tryToResolveConflict(oid, old, serial, data) rdata = self.tryToResolveConflict(oid, old, serial, data)
self.changes.store(oid, old, rdata, '', transaction, True) self.changes.store(oid, old, rdata, '', transaction)
self._resolved.append(oid)
else: else:
self.changes.store(oid, serial, data, '', transaction) self.changes.store(oid, serial, data, '', transaction)
...@@ -364,6 +366,13 @@ class DemoStorage(ConflictResolvingStorage): ...@@ -364,6 +366,13 @@ class DemoStorage(ConflictResolvingStorage):
self.changes.tpc_begin(transaction, *a, **k) self.changes.tpc_begin(transaction, *a, **k)
self._transaction = transaction self._transaction = transaction
self._stored_oids = set() self._stored_oids = set()
del self._resolved[:]
def tpc_vote(self, *a, **k):
if self.changes.tpc_vote(*a, **k):
raise ZODB.POSException.StorageTransactionError(
"Unexpected resolved conflicts")
return self._resolved
def tpc_finish(self, transaction, func = lambda tid: None): def tpc_finish(self, transaction, func = lambda tid: None):
with self._lock: with self._lock:
......
...@@ -520,6 +520,7 @@ class FileStorage( ...@@ -520,6 +520,7 @@ class FileStorage(
if oldserial != committed_tid: if oldserial != committed_tid:
data = self.tryToResolveConflict(oid, committed_tid, data = self.tryToResolveConflict(oid, committed_tid,
oldserial, data) oldserial, data)
self._resolved.append(oid)
pos = self._pos pos = self._pos
here = pos + self._tfile.tell() + self._thl here = pos + self._tfile.tell() + self._thl
...@@ -534,9 +535,6 @@ class FileStorage( ...@@ -534,9 +535,6 @@ class FileStorage(
raise FileStorageQuotaError( raise FileStorageQuotaError(
"The storage quota has been exceeded.") "The storage quota has been exceeded.")
if old and oldserial != committed_tid:
self._resolved.append(oid)
def deleteObject(self, oid, oldserial, transaction): def deleteObject(self, oid, oldserial, transaction):
if self._is_read_only: if self._is_read_only:
raise ReadOnlyError() raise ReadOnlyError()
......
...@@ -43,7 +43,6 @@ class MappingStorage(object): ...@@ -43,7 +43,6 @@ class MappingStorage(object):
self._commit_lock = ZODB.utils.Lock() self._commit_lock = ZODB.utils.Lock()
self._opened = True self._opened = True
self._transaction = None self._transaction = None
self._resolved = []
self._oid = 0 self._oid = 0
###################################################################### ######################################################################
...@@ -233,7 +232,7 @@ class MappingStorage(object): ...@@ -233,7 +232,7 @@ class MappingStorage(object):
# ZODB.interfaces.IStorage # ZODB.interfaces.IStorage
@ZODB.utils.locked(opened) @ZODB.utils.locked(opened)
def store(self, oid, serial, data, version, transaction, resolved=False): def store(self, oid, serial, data, version, transaction):
assert not version, "Versions are not supported" assert not version, "Versions are not supported"
if transaction is not self._transaction: if transaction is not self._transaction:
raise ZODB.POSException.StorageTransactionError(self, transaction) raise ZODB.POSException.StorageTransactionError(self, transaction)
...@@ -247,8 +246,6 @@ class MappingStorage(object): ...@@ -247,8 +246,6 @@ class MappingStorage(object):
oid=oid, serials=(old_tid, serial), data=data) oid=oid, serials=(old_tid, serial), data=data)
self._tdata[oid] = data self._tdata[oid] = data
if resolved:
self._resolved.append(oid)
checkCurrentSerialInTransaction = ( checkCurrentSerialInTransaction = (
ZODB.BaseStorage.checkCurrentSerialInTransaction) ZODB.BaseStorage.checkCurrentSerialInTransaction)
...@@ -284,7 +281,6 @@ class MappingStorage(object): ...@@ -284,7 +281,6 @@ class MappingStorage(object):
old_tid = None old_tid = None
tid = ZODB.utils.newTid(old_tid) tid = ZODB.utils.newTid(old_tid)
self._tid = tid self._tid = tid
del self._resolved[:]
# ZODB.interfaces.IStorage # ZODB.interfaces.IStorage
@ZODB.utils.locked(opened) @ZODB.utils.locked(opened)
...@@ -321,7 +317,6 @@ class MappingStorage(object): ...@@ -321,7 +317,6 @@ class MappingStorage(object):
if transaction is not self._transaction: if transaction is not self._transaction:
raise ZODB.POSException.StorageTransactionError( raise ZODB.POSException.StorageTransactionError(
"tpc_vote called with wrong transaction") "tpc_vote called with wrong transaction")
return self._resolved
class TransactionRecord: class TransactionRecord:
......
...@@ -390,8 +390,6 @@ stored are discarded. ...@@ -390,8 +390,6 @@ stored are discarded.
... '', t) ... '', t)
>>> bool(blob_storage.tpc_vote(t)) >>> bool(blob_storage.tpc_vote(t))
False False
>>> oldserial < blob_storage._tid
True
>>> blob_storage.tpc_abort(t) >>> blob_storage.tpc_abort(t)
Now, the serial for the existing blob should be the same: Now, the serial for the existing blob should be the same:
......
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