Commit 68d203be authored by Vincent Pelletier's avatar Vincent Pelletier

Decide to allow undoing transaction on object data rather than TID.

This fixes the inability to undo T-1 after undoing T.
For reference, this is what is done in RelStorage. It is not as restrictive
as FileStorage, but implementing the same support would/will take more
time.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1877 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 6042488a
......@@ -805,21 +805,22 @@ class Application(object):
oid_list = self.local_var.txn_info['oids']
# Second get object data from storage node using loadBefore
data_dict = {}
# XXX: this way causes each object to be loaded 3 times from storage,
# this work should rather be offloaded to it.
for oid in oid_list:
current_data = self.load(oid)[0]
after_data = self.loadSerial(oid, transaction_id)
if current_data != after_data:
raise UndoError("non-undoable transaction", oid)
try:
result = self.loadBefore(oid, transaction_id)
data = self.loadBefore(oid, transaction_id)[0]
except NEOStorageNotFoundError:
if oid == '\x00' * 8:
# Refuse undoing root object creation.
raise UndoError("no previous record", oid)
else:
# Undo object creation
result = ('', None, transaction_id)
data, start, end = result
# end must be TID we are going to undone otherwise it means
# a later transaction modify the object
if end != transaction_id:
raise UndoError("non-undoable transaction", oid)
data = ''
data_dict[oid] = data
# Third do transaction with old data
......
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