Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Duplicate txn.call_after calls when transactions are retried #12184

@squahtx

Description

@squahtx

Synapse provides the ability for database transactions to defer some processing until after the transaction succeeds or fails, via the Cursor.call_after and Cursor.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 same after_callbacks list is reused. This means that if a transaction fails, then succeeds on the next attempt, the after_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 or call_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 out after_callbacks in between attempts, MultiWriterIdGenerator would break.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4(OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patchesS-TolerableMinor significance, cosmetic issues, low or no impact to users.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions