Skip to content

commit() can raise after a transaction was applied, and a failing BatchWriter block drops queued writes #83

Closed

Description

@fctl-sh

Priority: medium.

  • commit() can raise after DynamoDB applied the transaction (transactions.py, the refresh after commit; repository.py, _evaluate). Instances are refreshed by evaluating the update on the item as it was loaded. For an unversioned instance whose item changed meanwhile, _apply_update can fail (list_append to an attribute another writer removed), and commit() raises a ValidationError, which normally means "not applied", leaving the instance unrefreshed. A caller who retries applies the change twice. Refresh failures after a commit should not raise as if the commit failed (reload the item, or mark the instance as not loaded).
  • BatchWriter.__aexit__ drops the queued writes when the block raises (batch.py), including writes that a failed automatic flush inside await batch.put() kept queued, as the docs promise ("what a failed flush did not write stays queued"), because that exception ends the block. It may be intended, like transactions, but it is not documented.

Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions