Skip to content

fix(service): the last rate limit of a request holds every worker until its wait ends - #2529

Merged
dan-petty merged 4 commits into
mainfrom
fix/2523-last-rate-limit-holds-every-worker
Oct 28, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/2523-last-rate-limit-holds-every-worker

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A review of #2515 found that the last rate limit of a request held no other worker. The session set the hold only for a refusal that it sent again, and run_gh returned from its backoff before the hold on its last attempt. So the refusal that failed the round held nothing, and the other workers sent requests at once, although GitHub asked for a wait with no request.

  • The session's retry_wait and run_gh's _handle_attempt_backoff hold every request of the identity for the wait of each rate limit, the last one too, before they decide whether a retry is left. The last attempt records no throttle and sleeps no wait. SessionGitHubAPI.handle_rate_limit_error loses its early return for a spent retry count.
  • A test sends a secondary limit to each attempt of one worker's request, through the session and through gh, with each wait moving the clock, and finds that the next worker's request waits for the last refusal's wait. It also fails when the hold in run_gh's backoff is removed, which no test caught before.
  • A test starts the Service through devops serve --service over a halt record and a budget record, and finds the Service halted with the requests of the window counted. It fails when serve.py gives no state_dir.
  • The rule comment above RoadmapServiceIdentityRefused says that a halt stays after a restart. ServeMessages.state_unreadable and the comments that fix(service): a restart keeps the halt, the budget window and the failure ledger, and a secondary limit or a suspended installation stops every worker #2474 added say "cannot" in place of "can't".

Change: openspec/changes/archive/2026-10-28-2523-last-rate-limit-holds-every-worker/

Closes #2523

…il its wait ends

The session and run_gh held the identity's requests only for a rate limit that they sent again, so the refusal that failed the round held nothing. Both now hold the requests before they decide whether a retry is left. A test moves the clock at each wait and covers both paths.
… halt and budget records

No test failed when serve.py gave the Service no state directory.
@dan-petty

Copy link
Copy Markdown
Owner Author

Local results on the branch, before the rebase onto 0379f21:

  • uv run devops ci fail-to-pass --base origin/main: 2 failed on base. Both are the cases of test_the_last_rate_limit_of_a_request_holds_every_worker_until_its_wait_ends (the-session and gh). On base, the next worker's request waited 0.12 s and 0.10 s, not 60 s.
  • Full suite (pytest -n 8 tests/): 12046 passed, 2 skipped.
  • After the rebase: the changed tests, the rate limiter, session and alert tests, tests/test_swallowed_failures_ratchet.py and tests/test_architectural_invariants.py gave 450 passed, 2 skipped. uv run mypy src found no issues.
  • Mutation checks: with limiter.hold_requests(backoff) removed from _handle_attempt_backoff, the gh case fails. With limiter.hold_requests(wait) removed from retry_wait, the the-session case and the earlier secondary-limit test fail. With state_dir=state_dir, removed from serve.py, test_the_service_that_serve_starts_reads_its_halt_and_budget_from_the_volume fails with (0, False, 0) != (0, True, 60).

The review findings of #2515 that this pull request delivers: 1 (the last refusal holds nothing), 2 (no test of the gh hold), 3 (no test of the serve state wiring), 4 and 5 (the same stale rule comment), 6 (the contraction).

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 20:30
@dan-petty
dan-petty merged commit 657b03d into main Oct 28, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2523-last-rate-limit-holds-every-worker branch October 28, 2026 20:30
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.11.2](v0.11.1...v0.11.2)
(2026-10-28)


### Bug Fixes

* **service:** the last rate limit of a request holds every worker until
its wait ends
([#2529](#2529))
([657b03d](657b03d)),
closes [#2523](#2523)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(service): the last rate limit of a request holds every worker, and tests cover the gh hold and the serve state wiring

1 participant