Repository navigation
Media: the window-reread test times its wait from before the stop's sleep (flaky on loaded runners) - #1382
Merged
Conversation
…leep `the_window_reread_waits_for_the_outgoing_stop_within_its_bound` took its `started` clock inside the spawned reader, while the 250 ms sleep that holds the stop back runs on the test thread right after the spawn. A reader the scheduler starts late (a loaded 4-vCPU runner) began its clock after that sleep had already begun, so a read that correctly waited for `stop.finish()` measured under 250 ms and failed `read >= 250ms` (249.328727ms in CI on 2026-11-12, PR #1355, and on 2026-11-14, PR #1380, run 43551876055). The clock now starts before the reader is spawned, so before the sleep can begin; the reader still returns `started.elapsed()` right after the re-read returns, so the bound still states that the read could not finish before the stop landed. The causal facts stay asserted by `window_reads()` being 0 at the 250 ms mark and 1 after the join. The bound is unchanged. The "stop that never lands" half starts and stops its clock on one thread around one call and needs no change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
GLinnik21
pushed a commit
that referenced
this pull request
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What failed
plx_media::route::decision::queue_predecessor_tests::the_window_reread_waits_for_the_outgoing_stop_within_its_bound(adevtriggerstest inside thehostsimpass) failed in CI twice with the same message:Cause
let started = Instant::now()was taken INSIDE the spawned reader thread, while the 250 msstd::thread::sleepthat holds the stop back runs on the test thread right afterscope.spawn. When the scheduler starts the reader late (a loaded 4-vCPU runner), the reader's clock starts after the test thread's sleep has already begun. A read that correctly waited forstop.finish()then measures under 250 ms, soread >= 250msfails although the code under test behaved.The causal facts were already asserted separately and are not affected:
fx.pms.window_reads()is 0 at the 250 ms mark and 1 after the join.Fix (test only)
startedis taken beforestd::thread::scope, so before the reader exists and before the sleep can begin. The reader still returnsstarted.elapsed()right afterrefreshed_withinreturns, so the assertion keeps its meaning: the read could not finish before the stop landed. The 250 ms bound is unchanged and the assertion stays.The other half of the test (the stop that never lands) starts and stops its clock on one thread around one call, so it has no cross-thread comparison and is unchanged. The only other
sleepin the file is the mock PMS's accept poll (2 ms), which is not compared against any clock.Demonstration
A 50 ms
std::thread::sleepwas put at the very start of the reader closure, beforestarted, to stand in for a reader the scheduler starts late (a smaller delay is not reliable: the reader's elapsed also includes the window read after the stop lands).Old code, with the delay:
Fixed code, same delay still in:
The delay was then removed (
grep -c DEMO-ONLYis 0 on the committed file; the diff is only the moved clock and its comment).Gates
make test-hostsim C=plx_media T=queue_predecessor_testson the committed tree (git status --shortempty before and after):Not run:
make check(test-only change in one file, gated by the CI lanes), the TV (no device behavior involved).🤖 Generated with Claude Code