Skip to content

Test harness: drop async mutating methods at each await point #2032

Open

Description

@bplatz

Several bugs have had the same shape. A method moves state out of self, or changes part of it, and then awaits. A caller that drops the future at that await leaves self torn: a timeout, a select!, an HTTP client that disconnects. #1261 and #1718 were fixed one at a time, and review of #2023 found two more in Transaction: rollback_to, and a stage that failed or was dropped.

A harness could catch the whole class instead:

  1. For each public async method that takes &mut self, or changes shared state, poll it with a no-op waker.
  2. Drop it after its 1st, 2nd, … Nth Pending.
  3. Check the object's invariants.
  4. Check that a follow-up call behaves as if the dropped call never ran, or ran in full.

The hard part is that many paths never return Pending in tests. Staging over novelty, or over a file-backed index, completes on its first poll, so a dropped call can't be reproduced there. The harness needs injected yield points, for example:

  • a storage wrapper that yields once per read, or
  • a test hook that yields at chosen awaits.

Until then, the #2023 tests make the same awaits fail, by exceeding a fuel limit, as a deterministic stand-in for a drop.

Raised in review of #2023.

Activity

  1. added
    enhancement
    P3
    area:transact
    on Oct 7, 2026
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

    P3area:transactenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions