From 50d47759bbd239a7b6ae6cec8ee27337fa090a9f Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 06:57:37 +0300 Subject: [PATCH] Media: the window-reread test times its wait from before the stop's sleep `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 --- .../media/src/route/decision_queue_predecessor_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust-modules/media/src/route/decision_queue_predecessor_tests.rs b/rust-modules/media/src/route/decision_queue_predecessor_tests.rs index 5c885e707f..a2664201b4 100644 --- a/rust-modules/media/src/route/decision_queue_predecessor_tests.rs +++ b/rust-modules/media/src/route/decision_queue_predecessor_tests.rs @@ -301,9 +301,13 @@ fn the_window_reread_waits_for_the_outgoing_stop_within_its_bound() { // The outgoing episode's stop is announced and still on its way. let stop = TIMELINE_STOP_FENCE.announce(); let waiting = continuation.clone().awaiting(TIMELINE_STOP_FENCE.announced()); + // The clock starts HERE, before the reader exists and so before the sleep below can begin: a + // reader the scheduler starts late (a loaded runner) must not shorten what this measures. Taken + // inside the reader, a late start put its clock after the sleep's, and a read that did wait for + // the stop measured under 250 ms. + let started = std::time::Instant::now(); let read = std::thread::scope(|scope| { let reader = scope.spawn(|| { - let started = std::time::Instant::now(); let _ = waiting.refreshed_within(client, Duration::from_secs(20)); started.elapsed() });