Skip to content

Harden Netty request-timeout tests against JVM stalls - #5549

Merged
adamw merged 1 commit into
masterfrom
harden-netty-request-timeout-tests
Sep 26, 2026
Merged

adamw merged 1 commit into
masterfrom
harden-netty-request-timeout-tests

Conversation

@adamw

@adamw adamw commented Sep 26, 2026

Copy link
Copy Markdown
Member

Fixes a flaky test introduced in #5466 (seen on master in run 36243258343).

The "respond with status 503, not 408" test and the "properly update metrics when a request times out" test made the server logic Thread.sleep for 2x the 1s request timeout. That leaves a 1s margin. On CI, a ~2.4s whole-JVM stall (visible as a gap in all suites' output) delayed both the timeout task and the sleeping logic. When the JVM resumed, the logic completed first, the 200 was written, and the timeout handler was removed. Result: List("HTTP/1.1 200 OK", "HTTP/1.1 200 OK") instead of 200, 503.

Now the logic blocks on a latch that is released only after the client has read the timeout response. The timeout always fires first, however long the JVM is stalled. The latch wait is bounded, so a failing test doesn't leave a blocked thread behind.

Side effect: both tests are about 1s faster, since nothing sleeps anymore.

Verified locally by freezing the sbt JVM (SIGSTOP) for 2.5s right after the test server binds: passes 3/3 with this change.

🤖 Generated with Claude Code

The "503, not 408" and "metrics when a request times out" tests made
the server logic sleep for 2x the 1s request timeout. On CI a ~2.4s
whole-JVM stall let the logic finish before the timeout task ran, so
the server answered 200 instead of 503 (master run 36243258343).

The logic now blocks on a latch that the test releases only after the
client has read the timeout response, so the timeout always fires
first. The tests also run about 1s faster.
@adamw
adamw merged commit 918a074 into master Sep 26, 2026
42 of 44 checks passed
@adamw
adamw deleted the harden-netty-request-timeout-tests branch September 26, 2026 17:49
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