Skip to content

fix(s3): stop the acceleration recovery test's precondition racing its own backoff - #519

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/acceleration-recovery-precondition-races-the-backoff
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/acceleration-recovery-precondition-races-the-backoff

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

main is red. The test job on dc69e64 failed like this:

--- FAIL: TestTheAccelerateEndpointComesBackWithinTheBackoff (0.10s)
    acceleration_recovery_test.go:174: acceleration is still active, so nothing was
    withdrawn and this test cannot observe a recovery

The diagnosis in that message is wrong, which is the interesting part. Something was
withdrawn. The log line immediately above the failure is:

INFO Retrying S3 Transfer Acceleration after backoff breaker=s3-acceleration backoff=25ms

The withdrawal happened, and the 25ms backoff had already expired by the time the guard
looked. The guard conflated two states Active cannot distinguish: never withdrawn, and
withdrawn and already recovered.

It is worse than a plain timing window, too. Reading the gate is what performs the
open→half-open transition that sets Active back to true — TestAccelerationStatsDoesNot- ReportAStateItJustChanged in the same file asserts that exact mechanism from the other
side. So under load this guard could cause the recovery it exists to rule out, and then
blame the gate for a fault that belonged to the clock.

The fix

Assert on something monotonic. Fallbacks is incremented on exactly the withdrawal path
(executeWithAccelerationFallback → RecordFallbackEvent) and only ever counts up, so no
amount of elapsed time can make it lie in either direction:

if backend.AccelerationStats().Fallbacks == 0 {

Verified by mutation, because a vacuity guard that no longer fires is worse than no
guard: dropping the injected fault so nothing is ever withdrawn leaves the test failing with
no fallback was recorded, at the guard. It still catches the vacuous run it exists for. 20
runs under -race alongside the sibling acceleration test, clean.

Only this one assertion needed it

The file's four other Active reads are safe on purpose, and I checked each rather than
changing them all:

line test's AccelerationRetry why it is safe
78 time.Hour the gate cannot reopen underneath it
204 25ms asserts the state after the gate reached StateClosed
257 25ms deliberately sleeps 2*retry and asserts the post-transition state
322 time.Hour the gate cannot reopen underneath it

I also added the rule to the test's doc comment rather than leaving two separate fixes: in
this test no assertion may read an instantaneous acceleration state, because the entire point
of a 25ms retry is that every such state changes on its own within 25ms.

Provenance

Exposed rather than caused by #516. That PR added ~1000 lines of parallel test to this
package, and the extra load is what makes a 25ms window get missed — the same load that made
the #515 data race deterministic in the same job, having been about one run in twenty locally.
Neither is a defect in the seekable read path; both are pre-existing timing assumptions that
only held while the package was lighter.

No CHANGELOG entry: this is a test precondition with no user-facing behaviour attached.

…s own backoff

main is red. TestTheAccelerateEndpointComesBackWithinTheBackoff failed its vacuity
guard — "acceleration is still active, so nothing was withdrawn and this test cannot
observe a recovery" — and that diagnosis was wrong. The withdrawal did happen; the log
line immediately above the failure is "Retrying S3 Transfer Acceleration after backoff
backoff=25ms". The 25ms backoff had already expired by the time the guard looked.

So the guard conflated two states it cannot tell apart: never withdrawn, and withdrawn
and already recovered. Reading Active is also what performs the open→half-open
transition that sets it back to true — TestAccelerationStatsDoesNotReportAStateItJust-
Changed asserts that exact mechanism from the other side — so under load the guard could
cause the recovery it exists to rule out, then blame the gate for a fault that was the
clock's.

The fix is to assert on something monotonic. Fallbacks counts exactly this withdrawal
and only ever counts up, so no amount of elapsed time can make it lie in either
direction. Verified by mutation: dropping the injected fault leaves the guard firing
with the right message, so it still catches the vacuous run it exists for. 20 runs
under -race with the sibling acceleration test alongside it, clean.

Only this one assertion needed it. The file's four other Active reads are safe on
purpose: three are in tests configuring a one-hour retry, where the gate cannot reopen
underneath them, and the fourth deliberately sleeps 2*retry and asserts the
post-transition state.

Exposed rather than caused by #516: that PR added ~1000 lines of parallel test to this
package, and the extra load is what made a 25ms window get missed. The same load made
the #515 race deterministic in the same job. No CHANGELOG entry — this is a test
precondition, with no user-facing behaviour attached.
@scttfrdmn
scttfrdmn merged commit 6278509 into main Sep 17, 2026
43 checks passed
@scttfrdmn
scttfrdmn deleted the fix/acceleration-recovery-precondition-races-the-backoff branch September 20, 2026 05:25
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.

1 participant