Skip to content

MongoDB: no test covers the re-run of a write transaction after a write conflict #968

Open

Description

@LeeroyHannigan

On MongoDB, a write transaction that fails with a write conflict (code 112, or the TransientTransactionError label) runs again, up to 50 attempts (TRANSIENT_RETRY_ATTEMPTS). After the last attempt the write answers 503. #475 adds this path for the stream sequence counter. Only the unit tests of the error classification (write_conflict::transaction_error) cover it.

test_racing_puts_and_deletes_on_a_stream_table_all_succeed in tests/test_stream_write_contention.py sends a write again after each 503, up to 20 times (_resend_unavailable, lines 147 to 163 at b349959). So this test also passes on a server that answers 503 at the first write conflict and never runs the transaction again.

Raised in the review of #475.

Proposed work: add a MongoDB test hook that makes the next N attempts of a write transaction fail with a write conflict. A test sets N below 50, sends one PutItem to a stream table, and requires a 200 and exactly one stream record.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions