Skip to content

impl(042): the runtime cases run on one thread - #426

Merged
bartekus merged 1 commit into
mainfrom
impl/042-runtime-case-race
Oct 31, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/042-runtime-case-race

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Fixes the intermittent failure of conformance::every_runtime_case_through_both_transports_and_listeners (seen in #422's merge group, run 41139262023): runtime.retry's delivered record differed.

Cause: the test ran on a 4-thread runtime. The driver could read the runtime's gauges in the middle of the decision's poll, after the topic attempt answered and released its permit and before explicit_deadline was dispatched. It then saw "retry timer pending, nothing in flight" and advanced the manual clock early, so explicit_deadline was recorded as dispatched or ended at 10 ms instead of 0. Reproduced under CPU load with the old binary: 2 failures in 80 runs. The captured records show exactly that difference.

Fix: the test now runs on a current-thread runtime, as the suite's native runner (tools/rustev-conformance/src/runtime.rs) drives the same cases. The driver then reads gauges and sleepers only between the decision's polls. No retries were added, and the byte comparison is unchanged. Under the same load the fixed binary passed 96 of 96 runs.

Checks: the stress runs above, make gate, scripts/check-authored-content.sh.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

The PR makes two related changes: switching the every_runtime_case_through_both_transports_and_listeners test from a 4-worker multi-thread Tokio runtime to the default current-thread runtime, and adding a spec paragraph in 042 documenting the rationale.

Code change (runner.rs): The fix is technically sound. #[tokio::test] without arguments defaults to flavor = "current_thread", which matches the stated intent. The race described in the comment is real: on a multi-thread pool, the test driver could sample gauges mid-decision-poll (after one attempt's permit was released, before the next dispatch), causing the manual clock to advance early and producing non-deterministic timestamps in the golden comparison. Running on a current-thread runtime serialises driver reads and decision polls, eliminating the window. The fix is also consistent with how the native conformance runner (tools/rustev-conformance/src/runtime.rs) drives the same cases.

Spec change (spec.md): The addition records the incident date, the observed symptom, the root cause, and the mitigation. It does not alter any normative claim, ownership unit, lifecycle key, or authority edge. The spec already exists and is established; this is an informational addendum, not a ratification claim.

No bugs, security problems, or governance inconsistencies found.

{"head": "13aa810c85b79e2ead2d7222328c74713e53d2ca", "verdict": "no-findings", "findings": []}

Subject: 8517df9...13aa810, diff digest 8a02cc8caae23a98691a4554430a1da1e0c991e116f690703210573b75c08124, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 31, 2026
The runtime-case runner could read the runtime's gauges mid-poll on a
worker pool and step the manual clock before the next attempt was
dispatched. Drive it on a current-thread runtime, as the native runner
does.
@bartekus
bartekus force-pushed the impl/042-runtime-case-race branch from 13aa810 to e35cb32 Compare October 31, 2026 00:07
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

The PR makes two related changes: switching a tokio test from a 4-worker multi-threaded runtime to the default single-threaded (current_thread) runtime, and documenting that fix in spec 042.

Test change (runner.rs): The race condition described is real. With a worker pool, the conformance driver can interleave its gauge reads with the runtime's internal dispatch: after one attempt's permit is released but before the next attempt is dispatched, the driver sees "zero pending work" and advances the manual clock past the retry delay, causing explicit_deadline to appear at 10 ms instead of 0. Switching to #[tokio::test] (current-thread) eliminates the interleave because the driver's reads and the runtime's dispatches serialize on the single thread. The explanation in the comment is accurate and sufficient.

Spec change (spec.md): The addition appears in the implementation notes section for Increment 5, appended before ## Decisions at approval. It accurately describes the failure mode and the fix. No lifecycle rules are violated by the addition itself (it is an implementation note, not a new normative claim).

No bugs, security problems, or governance inconsistencies found.

{"head": "e35cb3284dabdbae97c010a6fc1dc0762493f35f", "verdict": "no-findings", "findings": []}

Subject: 2cfbfee...e35cb32, diff digest 73a77667e2aca5485f64125e20f8a22fb8b789a7fe6a57208d093f3b615bd15d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 682bde9 Oct 31, 2026
30 checks passed
@bartekus
bartekus deleted the impl/042-runtime-case-race branch October 31, 2026 01:31
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