This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Duplicate txn.call_after
calls when transactions are retried
#12184
Labels
P4
(OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patches
S-Tolerable
Minor significance, cosmetic issues, low or no impact to users.
T-Defect
Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Synapse provides the ability for database transactions to defer some processing until after the transaction succeeds or fails, via the
Cursor.call_after
andCursor.call_on_exception
methods. These methods append the given callback to an internal list which gets run once the transaction is done.When a transaction fails with a SerializationFailure, Synapse will retry it up to 5 times (inside
new_transaction
). Although a new Cursor is created for each attempt, the sameafter_callbacks
list is reused. This means that if a transaction fails, then succeeds on the next attempt, theafter_callbacks
from the previous failed attempt will also run.These callbacks are mostly used for cache invalidation, so this is probably okay?
Note that MultiWriterIdGenerator needs either the
call_after
orcall_on_exception
callbacks from failed transaction attempts to run, otherwise it wouldn't know when the ids handed out to failed transactions are done. If we were to clear outafter_callbacks
in between attempts, MultiWriterIdGenerator would break.The text was updated successfully, but these errors were encountered: