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

Closed

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.

Activity

  1. added
    S-TolerableMinor significance, cosmetic issues, low or no impact to users.
    T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.
    on Mar 8, 2022
  2. clokep commented on Mar 9, 2022

    @clokep
    Member

    Does this need discussion of what the proper behavior should be?

  3. squahtx commented on Mar 9, 2022

    @squahtx
    ContributorAuthor

    Probably? Let's stick it in the needs-discussion bucket.

  4. callahad commented on Mar 10, 2022

    @callahad
    Contributor

    Conclusion from meeting: let's note this behavior in in the call_* function docstrings, but leave the behavior unchanged.

    There are legitimate uses for both modalities, so if we wanted to address it we'd likely want to extend the API surface to indicate whether duplicate callbacks should be enqueued or not. But we'll hold off on that until we have a concrete motivation to make the change.

  5. added
    P4(OBSOLETE: use S- labels.) Okay backlog: will not schedule, will accept patches
    and removed on Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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