Skip to content

Fix two transaction hangs, and other CI flakes - #134

Open
rjhuijsman wants to merge 4 commits into
mainfrom
rjh.deflake-concurrent-transactions-same-state
Open

Fix two transaction hangs, and other CI flakes#134
rjhuijsman wants to merge 4 commits into
mainfrom
rjh.deflake-concurrent-transactions-same-state

Conversation

@rjhuijsman

@rjhuijsman rjhuijsman commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

CI is currently ~unpassable because of CI flakes. Most notably //tests/reboot/pydantic/concurrent_transactions_same_state:test_py is ~80% flaky. An agent identified two hangs in the transaction code from those flakes. These each have their own commit to fix them, please see the individual commit descriptions for details.

Additionally, we address timeouts and flakes in MacOS CI that are due to overload by reducing its workload, removing tests that don't add meaningful coverage.

Note that while the first commit's case is proven with unit tests, the second is hard to repro so needs some human reasoning to validate.

@aviator-app

aviator-app Bot commented Aug 18, 2026

Copy link
Copy Markdown

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR is not ready to merge (currently in state pending): this PR has not been approved.

Pending Status Checks


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@rjhuijsman
rjhuijsman force-pushed the rjh.deflake-concurrent-transactions-same-state branch 3 times, most recently from c504154 to a4ba4d0 Compare August 18, 2026 15:55
@rjhuijsman rjhuijsman changed the title state_managers: don't hand a lock hold to a waiter that gave up Fix two transaction hangs causing CI flakes Aug 18, 2026
@rjhuijsman rjhuijsman changed the title Fix two transaction hangs causing CI flakes Fix two transaction hangs (which cause CI to flake) Aug 18, 2026
@rjhuijsman
rjhuijsman marked this pull request as ready for review August 18, 2026 16:01
@rjhuijsman
rjhuijsman requested review from benh and a balanced review from Copilot and removed request for benh August 18, 2026 16:01
@rjhuijsman rjhuijsman self-assigned this Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes transaction hangs caused by cancelled lock waiters and interrupted coordinator aborts.

Changes:

  • Safely discards abandoned lock waiters and restores interrupted upgrades.
  • Publishes coordinator aborts before cancellable cleanup.
  • Adds lock regression tests and increases a flaky test’s timeout class.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
reboot/aio/state_managers.py Updates lock and transaction-abort handling.
tests/reboot/state_manager_tests.py Adds cancellation regression tests.
tests/reboot/zod/concurrent_transactions_same_state/BUILD.bazel Increases the test size to large.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread reboot/aio/state_managers.py
Comment thread tests/reboot/zod/concurrent_transactions_same_state/BUILD.bazel Outdated
Comment thread tests/reboot/state_manager_tests.py Outdated
Comment thread reboot/aio/state_managers.py
@github-actions

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@rjhuijsman
rjhuijsman force-pushed the rjh.deflake-concurrent-transactions-same-state branch from 02800df to 0cb9773 Compare August 19, 2026 12:07
In the state manager, callers take `Lock`s per state - but before this
commit it was possible for a caller to be granted a `Lock` after the
caller was cancelled. In that case the `Lock` was never released again,
and the state it guarded became unusable for the life of the process.
That caused CI flakes.

Specifically, before this change, `Lock._maybe_grant_next()` would grant the
lock to the waiter at the head of its queue without checking whether that
waiter was cancelled or not. Cancellation of callers is routine, so
there were many ways CI runs could flake - the most common flake was the
new `//tests/reboot/pydantic/concurrent_transactions_same_state:test_py`
which flaked ~80% on MacOS (oof).

This commit makes it so that all forms of lock-taking will avoid
granting locks to waiters that have been cancelled.

Additionally, the `zod` version of `concurrent_transactions_same_state`
would regularly time out even without hitting the flake, so this commit
also bumps its timeout.

TESTED: five new unit tests cover all cases that used to be broken.
A participant only ever learns that its transaction aborted from
the coordinator, by watching it. If that news never arrives the
participant blocks forever, holds its state's lock forever, and any
retry reusing the same idempotency key blocks behind it.

Before this change, `_transaction_coordinator_abort()` resolved the
`_coordinator_participants` future last, after awaiting a database
cleanup and a fan-out of best-effort `Abort` RPCs whose own handler
re-raises `CancelledError`. A coordinator cancelled during either
await -- which is what happens when its caller goes away -- left
the future pending with nothing left to resolve it, blocking every
participant forever.

This commit reorders the abort to first resolve the future and drop
its entry, ahead of anything that can be interrupted. Answering
before the database cleanup lands is safe because an abort is never
something the coordinator records: the durable outcomes are "preparing"
and "absent", and recovery re-drives a "preparing" transaction into the
same abort.
@rjhuijsman
rjhuijsman force-pushed the rjh.deflake-concurrent-transactions-same-state branch 2 times, most recently from 26a92b8 to 80f5843 Compare August 19, 2026 12:21
Comment thread tests/reboot/examples/agent-wiki/BUILD.bazel Outdated
@github-actions

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@rjhuijsman
rjhuijsman force-pushed the rjh.deflake-concurrent-transactions-same-state branch from 013a472 to fac8d23 Compare August 19, 2026 12:36
Our MacOS runners are the slowest and most expensive ones we have,
and over-saturated runners cause frequent timeouts in our largest
tests. This commit removes several redundant large tests from its
coverage, reducing run time by ~51 minutes and hopefully reducing
over-saturated-runner timeout flakes.

Before this change, the MacOS job ran every test under `//tests/...`
that wasn't explicitly excluded — 219 targets, 28 of them `large` or
carrying a `long` timeout. Many of those tests don't tell us anything
that the Linux runners don't already tell us: they type-check TypeScript,
exercise pure application logic on top of the Reboot runtime. Other
`large` tests drive a toolchain (`uv sync`, `rbt generate`, `npm install`,
`rbt dev run`) that another test running on MacOS drives too. These
useless tests add up to ~51 minutes of MacOS runner usage per run.

This commit adds a `platform-independent` tag, which indicates tests
that don't add meaningful coverage for the MacOS platform. the MacOS job's
`bazel query` now excludes these.
@rjhuijsman
rjhuijsman force-pushed the rjh.deflake-concurrent-transactions-same-state branch from fac8d23 to a77547e Compare August 19, 2026 12:37
@github-actions

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Before this commit, the `agent-wiki`'s test asked for a `large` test;
we don't think it actually needs that. It claims it's for `uv sync`, but
we've not seen any recent evidence of a fully cold `uv sync` taking more
than ~1.2s. The target runs in 35-71s across the last 22 MacOS jobs,
comfortably inside a `medium` budget. The timeouts it _did_ have look
more like the hangs the previous commits fixed.

This commit therefore removes the `large` test request for `agent-wiki`.
@rjhuijsman
rjhuijsman force-pushed the rjh.deflake-concurrent-transactions-same-state branch from cca1867 to 061176e Compare August 19, 2026 13:08
@rjhuijsman

rjhuijsman commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@benh can you bump this to the top of your queue? These flakes make CI unpassable for all other PRs, and you're clearly the appropriate reviewer for transaction logic changes.

@github-actions

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@rjhuijsman rjhuijsman changed the title Fix two transaction hangs (which cause CI to flake) Fix two transaction hangs, and other CI flakes Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants