Skip to content

fix(moq-ffi): time the failing-first-dial test's dial on the test clock - #9431

Merged
kixelated merged 1 commit into
mainfrom
fix/session-state-timeout
Nov 22, 2026
Merged

kixelated merged 1 commit into
mainfrom
fix/session-state-timeout

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

moq-ffi test::session_state_names_a_failing_first_dial hung until nextest killed it at 120 s in Nightly run 45035580806 (Gate, ci: test rs). It is in the PR gate too.

The test's second half (the accepted session's lifecycle) reused the first half's config, so it dialed a real server with a 100 ms real-time dial timeout. Under CPU load the QUIC handshake outlasted it; a failed first dial ends the session without redialing (by design since #8478), and the test's unbounded server.accept().await waited forever.

Approach

Split the test in two:

  • session_state_names_a_failing_first_dial starts the FFI runtime on its Manual test clock (ffi::start_test_clock, as standalone_refresh_waits_out_the_interval does). It waits for the dial's first packet on the silent socket (the reconnect policy fixes the deadline before it sends), then advances the clock by the dial timeout. That makes it deterministic, and it no longer waits 100 ms of real time.
  • session_state_reports_an_accepted_session covers the accepted side on a real handshake. The QUIC handshake can't complete on a frozen clock, so it uses the default dial bound, binds an ephemeral port instead of reusing the silent socket's, and bounds every await by TIMEOUT.

Impact

None: test-only.

Alternatives

  • Keep one test on the Manual clock: the real handshake hangs at server.accept() with the clock frozen.
  • Drop only the 100 ms bound from the second half: fixes the hang, but the first half would still wait in real time.

Validation

  • Stress before the fix: 200 runs, 48 parallel, with 24 CPU hogs on 24 cores. 5 hung (exit 124 at 20 s).
  • After the fix, same load: session_state_names_a_failing_first_dial passed 400/400 and session_state_reports_an_accepted_session passed 400/400. Each runs in about 0.02 s.
  • Mechanism check: forcing a 1 ms dial timeout into the accepted-session test fails it every run at the server.accept() bound, the same await the old test hung on with no bound.
  • History: this failure appears only in that one run among the last five Nightly Gate jobs and 40 failed queue runs.
  • just check passed. quest review --harness codex (gpt-6.1-sol, high) found 0 findings.

Caused by

  • moq-dev/moq#8478: made a failed first dial final and added the accepted-side half reusing the 100 ms real-time dial bound, so a slow handshake ended the session while the test waited unbounded on accept (found by check).

Follow-ups

None.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: fe9310c

  • Base: origin/main at 1cdc73b

  • Risk: low, The only file changed is the test module `rs/moq-ffi/src/test.rs`, so nothing users, customers, or other repositories rely on can break, and a revert fully undoes it; the risk file lists tests as low.

  • Classified: low by Claude Code, claude-haiku-5-5, low effort, session 239157c3-53b7-407c-9d24-b11b499b0b1b

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a2047e-dd8e-74b0-84a2-77b98e26513d, round 1

  • Score: 9/10, Source review found no actionable defects in the deterministic test-only change, with tests intentionally not run.

  • Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

The test's second half dialed a real server with the first half's 100 ms
real-time dial timeout. Under CPU load the handshake outlasted it, the
first dial failed for good (by design since #8478), and the unbounded
server.accept() waited until nextest killed it.

Split it: the failing dial runs on moq-ffi's Manual test clock and fails
when the test advances it; the accepted-session lifecycle gets its own
test on an ephemeral port with no dial bound to race, and bounds every
await by TIMEOUT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2bcceb5-22fe-4c4d-817f-417f80297b9b
Commits

Reviewing files that changed from the base of the PR and between 1cdc73b and fe9310c.

Files selected for processing: 1

  • rs/moq-ffi/src/test.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Approach: sound. It splits the flaky test so the failing-dial half runs on the FFI runtime's Manual clock and is deterministic. The accepted-session half drops the 100 ms real-time dial bound that a slow handshake could outlast, and every await in it is now bounded.

Reviewed changes: I reviewed the single commit, which touches only rs/moq-ffi/src/test.rs.

  • session_state_names_a_failing_first_dial on the test clock: This half starts the runtime with ffi::start_test_clock(), the same pattern standalone_refresh_waits_out_the_interval uses. It waits for the dial's first packet on a silent tokio::net::UdpSocket and then advances the clock by DIAL. The ordering holds:
    • reconnect.rs dial() sets the deadline to now + timeout before it sends anything. On a frozen clock that deadline is T0+DIAL.
    • The Manual Timer::poll fires right away even if it is armed after the advance.
    • The test body's kio::clock::timeout watchdogs run on the #[tokio::test] runtime's host clock, because the Manual clock is installed per runtime id. They only fire if the test fails.
  • session_state_reports_an_accepted_session split out: This half uses a real handshake with the default dial bound and an ephemeral server port. listen, accept, and request.accept are now each wrapped in TIMEOUT, so a regression fails the test instead of hanging it until nextest kills it.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 52125fe Nov 22, 2026
7 checks passed
@kixelated
kixelated deleted the fix/session-state-timeout branch November 22, 2026 23:50
kixelated added a commit that referenced this pull request Nov 23, 2026
The Nightly hang it cites ran code from before #9431, which moved the
test's dial onto the manual clock. Every Nightly Gate since passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ksletmoe-aws pushed a commit to ksletmoe-aws/moq that referenced this pull request Nov 25, 2026
moq-dev#9497)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.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.

1 participant