Commit a9853038 authored by Jérome Perrin's avatar Jérome Perrin Committed by Kirill Smelkov

zodbcommit: include the status of transaction

even though the interface of IStorageRestorable.tpc_begin does not
have a "status" argument, it is described in the notes below that the
actual implementation uses it:

https://github.com/zopefoundation/ZODB/blob/0632974d/src/ZODB/interfaces.py#L950-L956

This is used by FileStorage:

https://github.com/zopefoundation/ZODB/blob/0632974d/src/ZODB/FileStorage/format.py#L30-L39

and the storage methods seem to accept this argument:

https://github.com/zopefoundation/ZODB/blob/0632974d/src/ZODB/BaseStorage.py#L182
https://github.com/zopefoundation/ZEO/blob/e5637818/src/ZEO/ClientStorage.py#L888
https://lab.nexedi.com/nexedi/neoppod/blob/fd87e153/neo/client/app.py#L473

Propagating the status fixes some cases where restoring commits did not
recreate a storage that is byte-to-byte equivalent. This happened with
a FileStorage that was packed and contained transactions with "p"
status.
Co-authored-by: Kirill Smelkov's avatarKirill Smelkov <kirr@nexedi.com>
Reviewed-on: nexedi/zodbtools!24
parent 1b480c93
......@@ -54,7 +54,7 @@ import warnings
#
# txn.tid acts as a flag:
# - with tid=0 the transaction is committed regularly.
# - with tid=!0 the transaction is recreated with exactly that tid via IStorageRestoreable.
# - with tid=!0 the transaction is recreated with exactly that tid and txn.status via IStorageRestoreable.
#
# tid of created transaction is returned.
_norestoreWarned = set() # of storage class
......@@ -76,7 +76,7 @@ def zodbcommit(stor, at, txn):
# supporting .restore, it can still support .tpc_begin(tid=...). An example
# of this is NEO. We anyway need to be able to specify which transaction ID
# we need to restore transaction with.
stor.tpc_begin(txn, tid=txn.tid)
stor.tpc_begin(txn, tid=txn.tid, status=txn.status)
runctx = "%s: restore %s @%s" % (stor.getName(), ashex(txn.tid), ashex(at))
else:
stor.tpc_begin(txn)
......
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