Skip to content

test(client): make the idle-lane surplus release test deterministic - #2241

Merged
yigitdot merged 2 commits into
mainfrom
fix/2240-idle-lane-release-flake
Sep 30, 2026
Merged

yigitdot merged 2 commits into
mainfrom
fix/2240-idle-lane-release-flake

Conversation

@yigitdot

@yigitdot yigitdot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2240.

Problem

an_idle_lane_releases_its_surplus_workers_before_the_drive_ends needed two release stamps to land at least 300ms before the drive ended, while the slow lane slept 600ms in finish. The store does its I/O on spawn_blocking, so under a full parallel run the fast lane took longer than that window. The slow lane then took another gap and started a new stall, and the releases landed less than 300ms before the end (early == 0). The driver's release logic is correct; only the test was racy.

Fix

  • ScriptedSource::gated_finish(&'static Semaphore): each finish waits for a permit after its range is delivered.
  • The fast lane's second release opens the gate, so the slow lane's gap can finish only after two surplus workers have stopped. The drive is wrapped in a 20s timeout, so a regression fails clearly instead of hanging.
  • The third release records whether the gate was already open. A driver that lets its last idle worker go while another lane still holds a gap fails that check. Correct code cannot fail it under any load, because release docs: convert ASCII art schemas to Mermaid diagrams #3 needs the slow gap to finish, which needs the gate open. The gate opens 250ms after release docs: Generalize architecture to content-agnostic CDN, refocus slashing on bad edges #2; that delay only affects how reliably a regression is caught, not whether correct code passes.
  • The assertions now check: no fault on the fast lane, the drive succeeds, the slow lane took exactly one gap, the fast lane released 3 times, and the kept worker released last.

Verification

  • cargo nextest run -p decdn-client --no-fail-fast: 8/8 full parallel runs green on macOS across both commits. Before the fix, 3/3 runs failed.
  • Mutation live.load(..) > 1 → > 0 in the driver (the kept worker leaves too): the test fails 5/5 on the kept-worker assertion.
  • Mutation > 1 → > 99 (surplus workers never leave): the test fails through the 20s timeout.
  • cargo clippy --workspace --all-targets -- -D warnings, cargo fmt -- --check, and cargo doc -p decdn-client with -D warnings all pass.

🤖 Generated with Claude Code

…ll-clock timing (#2240)

The slow lane's finish now waits on a semaphore that the fast lane's
second surplus release opens, so the ordering the test asserts no longer
depends on CPU load. A lane that keeps its surplus workers fails the
test through a 20s timeout instead of passing or hanging.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-code-quality

github-code-quality Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit be832e1 in the fix/2240-idle-lane-r... branch remains at 86%, unchanged from commit 74e2cd4 in the main branch.


Updated September 29, 2026 19:25 UTC

…p is held

The gate now opens a while after the second release, and the third
release records whether the gate was already open. A driver that lets its
last idle worker go while another lane still holds a gap fails the new
kept-worker assertion; correct code cannot fail it under any load. Also
asserts the fast lane never faults and the slow lane takes exactly one
gap, and tightens the gate docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot
yigitdot enabled auto-merge (squash) September 29, 2026 22:30
@yigitdot
yigitdot disabled auto-merge September 29, 2026 22:31
@yigitdot
yigitdot merged commit a366f1a into main Sep 30, 2026
30 checks passed
@yigitdot
yigitdot deleted the fix/2240-idle-lane-release-flake branch September 30, 2026 00:03
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.

Flaky under load: driver::tests::an_idle_lane_releases_its_surplus_workers_before_the_drive_ends

3 participants