From 44d4af6924e56fe061c541f86b654e81d4e0f4e3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 13 Oct 2026 11:34:53 -0700 Subject: [PATCH 1/3] chore: claim quiet-edge regression quest Co-Authored-By: Codex From 6f56a93bcd0affee2488f83a09e2738427797ee5 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 13 Oct 2026 11:59:23 -0700 Subject: [PATCH 2/3] test(net): pin quiet catalog retention across rejoin and takeover Co-Authored-By: Codex --- quest/m0/release-22/quiet-edge.md | 2 +- quest/m1/README.md | 1 - quest/m1/quiet-edge-test.md | 22 ----- rs/moq-net/tests/rejoin.rs | 135 ++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 24 deletions(-) delete mode 100644 quest/m1/quiet-edge-test.md diff --git a/quest/m0/release-22/quiet-edge.md b/quest/m0/release-22/quiet-edge.md index d294772a2f9..6fd51356175 100644 --- a/quest/m0/release-22/quiet-edge.md +++ b/quest/m0/release-22/quiet-edge.md @@ -25,7 +25,7 @@ returns early on a finished held group, so takeover loses it the same way. Decided 2026-10-13 (maintainer): -- Backport to `release` only; `main` gets [a regression test](/quest/m1/quiet-edge-test.md). +- Backport to `release` only; `main` already has quiet rejoin and takeover regression tests. - Keep the `WarmCopy` alive and unfinished until the new copy delivers a group newer than its edge, so the one existing rule (a live track's latest is protected) covers it. Give `retire` the same treatment for a diff --git a/quest/m1/README.md b/quest/m1/README.md index bd3068cdf7b..1c9249bb885 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -67,7 +67,6 @@ disabled rung strands WHEP, HLS, and moq-mux export viewers. - [Interop close logs](/quest/m1/interop-close-log.md) - logging fix landed; delete once the required Interop run is green - [One max_age meaning](/quest/m1/cache-max-age.md) - a superseded group goes stale on wall clock since its successor arrived or on media time, whichever is first, in Rust and js/net; fixes the untimed failover stall -- [Quiet latest group test](/quest/m1/quiet-edge-test.md) - pins on `main` that a quiet track's latest group survives rejoin, expiry, and takeover - [FETCH max-delay](/quest/m1/fetch-max-delay.md) - historical readers obey publisher max-age and an optional tighter reader budget, including while holding a group - [Claim answer epochs](/quest/m1/claim-answer-epochs.md) - a claim answers each output by publishing it at its exact path under its own epoch, so a restarted output never reaches a returning reader as the old one's cache - [Untimed decisions](/quest/m1/untimed-decisions.md) - the maintainer decides whether moq-archive keeps refusing untimed tracks, and whether a malformed FETCH object ends its track diff --git a/quest/m1/quiet-edge-test.md b/quest/m1/quiet-edge-test.md deleted file mode 100644 index 65efa7f3be1..00000000000 --- a/quest/m1/quiet-edge-test.md +++ /dev/null @@ -1,22 +0,0 @@ -# [XS] Pin a quiet track's latest group across rejoin and takeover - -## Goal - -`rs/moq-net/tests/rejoin.rs` proves that a late subscriber to a live, quiet -track receives its latest group after readers left and rejoined and the cache -expiry passed, and after a publisher takeover, on every version, while a -superseded group still expires. - -## Plan - -`main` already behaves (verified 2026-10-13), but the 0.17 line broke it -([#5413](https://github.com/moq-dev/moq/issues/5413)); the test keeps a -future origin rework from regressing. Decided 2026-10-13 (maintainer): land -the port of the reporter's test plus a takeover variant, on lite-05, 06 and -07 and transport-19 and 22, using `moq_net_sim::test` time. Mention #5413 -without a closing keyword; the [release backport](/quest/m0/release-22/quiet-edge.md) -closes it. - -## Related - -- [Release backport](/quest/m0/release-22/quiet-edge.md) - the 0.17 fix this pins on `main` diff --git a/rs/moq-net/tests/rejoin.rs b/rs/moq-net/tests/rejoin.rs index 9ccbcd8597b..2c0c23f75af 100644 --- a/rs/moq-net/tests/rejoin.rs +++ b/rs/moq-net/tests/rejoin.rs @@ -603,3 +603,138 @@ async fn rejoin_keeps_source_timestamps() { .unwrap_or_else(|_| panic!("{version}: timed out")); } } + +/// A quiet track's latest group outlives the cache window while it stays the live edge. +/// +/// A catalog is published once. A reader reads it and leaves, so the relay parks the +/// track, and the next reader re-splices the upstream copy after the cached group. The +/// group must stay protected while that reader holds the track open: a reader joining +/// after the cache window needs it, and no newer group may ever come. Once a newer group +/// supersedes it, it expires like any other. +#[moq_net_sim::test] +async fn rejoined_quiet_catalog_survives_cache_expiry() { + for version in [ + "moq-lite-05", + "moq-lite-06", + "moq-lite-07-wip", + "moq-transport-19", + "moq-transport-22", + ] { + quiet_catalog_survives_cache_expiry(version.parse().unwrap(), false).await; + } +} + +/// A quiet track's latest group outlives the cache window across a publisher takeover. +/// +/// The publisher reconnects while a reader holds the catalog. A late reader through the +/// new connection still needs the quiet catalog, even on a wire without epochs where +/// the old reader ends with its route. +#[moq_net_sim::test] +async fn taken_over_quiet_catalog_survives_cache_expiry() { + for version in [ + "moq-lite-05", + "moq-lite-06", + "moq-lite-07-wip", + "moq-transport-19", + "moq-transport-22", + ] { + quiet_catalog_survives_cache_expiry(version.parse().unwrap(), true).await; + } +} + +async fn quiet_catalog_survives_cache_expiry(version: Version, takeover: bool) { + moq_net_sim::timeout(TEST_TIMEOUT + moq_net::cache::DEFAULT_EXPIRY * 5, async { + let publisher = produce_origin(1); + let relay = produce_origin(2); + let broadcast = publisher.create_broadcast("bench").unwrap(); + let track = broadcast.create_track("catalog", timed()).unwrap(); + broadcast + .announce(moq_net::origin::Route::default().with_epoch(moq_net::Epoch::mint())) + .unwrap(); + let mut group = track.append_group().unwrap(); + group.write_frame(Timestamp::ZERO, b"catalog".as_ref()).unwrap(); + group.finish().unwrap(); + + let upstream = || { + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(publisher.consume()); + options.client_subscribe = Some(relay.clone()); + connect_mock(options) + }; + let mut upstream_session = upstream().await; + + // Each session gets its own hop, so the relay serves it through its own front. + let session = |hop| { + let relay = relay.clone(); + async move { + let client = produce_origin(hop); + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(relay.consume()); + options.client_subscribe = Some(client.clone()); + let pair = connect_mock(options).await; + let consumer = client.consume(); + consumer.routed("bench").await.unwrap(); + let remote = consumer.request_broadcast("bench", None).await.unwrap(); + let sub = remote.track("catalog").unwrap().subscribe(None).await.unwrap(); + (sub, remote, pair) + } + }; + + let (_holder, _holder_remote, _holder_pair) = if takeover { + // The publisher reconnects while the holder reads, and the old connection goes: + // the relay takes the track over from the new one. + let (mut holder, remote, pair) = session(3).await; + assert_eq!(holder.recv_group().await.unwrap().unwrap().sequence, 0, "{version}"); + let replacement = upstream().await; + // An equal route changes no announcement to wait on. The paused clock only + // advances once every task is idle, so this lets its announce land. + moq_net_sim::sleep(Duration::from_millis(100)).await; + upstream_session = replacement; + (holder, remote, pair) + } else { + // A reader leaves, so the relay parks the track; the holder re-splices it. + let (mut first, remote, pair) = session(3).await; + assert_eq!(first.recv_group().await.unwrap().unwrap().sequence, 0, "{version}"); + drop((first, remote, pair)); + track.demand().unused().await.unwrap(); + let (mut holder, remote, pair) = session(4).await; + assert_eq!(holder.recv_group().await.unwrap().unwrap().sequence, 0, "{version}"); + (holder, remote, pair) + }; + + moq_net_sim::sleep(moq_net::cache::DEFAULT_EXPIRY * 2 + Duration::from_secs(2)).await; + let (mut later, later_remote, _later_pair) = session(5).await; + let mut group = moq_net_sim::timeout(Duration::from_secs(1), later.recv_group()) + .await + .unwrap_or_else(|_| panic!("{version} takeover={takeover}: late reader lost the latest catalog")) + .unwrap() + .unwrap(); + assert_eq!(read_all(&mut group).await.unwrap(), [b"catalog"], "{version}"); + drop(group); + + // A newer catalog supersedes it, so the old one expires like any other group. + let mut newer = track.append_group().unwrap(); + newer + .write_frame(Timestamp::from_millis(1000).unwrap(), b"newer".as_ref()) + .unwrap(); + newer.finish().unwrap(); + // Epochless wires end the old holder on takeover. The late reader uses the + // current route on every version, and keeps that copy live for the expiry check. + assert_eq!(later.recv_group().await.unwrap().unwrap().sequence, 1, "{version}"); + moq_net_sim::sleep(moq_net::cache::DEFAULT_EXPIRY * 2 + Duration::from_secs(2)).await; + let old = async { + let mut group = later_remote.track("catalog").unwrap().fetch_group(0, None).await?; + group.read_frame().await + }; + assert!( + moq_net_sim::timeout(Duration::from_secs(1), old) + .await + .unwrap() + .is_err(), + "{version} takeover={takeover}: the superseded catalog never expired" + ); + drop(upstream_session); + }) + .await + .unwrap_or_else(|_| panic!("{version} takeover={takeover}: timed out")); +} From 4a54b9571fe681fbb5cf61e58fe41208a30119c2 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 14 Oct 2026 09:21:03 -0700 Subject: [PATCH 3/3] test(net): await the takeover route instead of sleeping Price the original upstream above the replacement, so the relay reports the new route taking over, and wait for that event before dropping the old connection. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/tests/rejoin.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/rs/moq-net/tests/rejoin.rs b/rs/moq-net/tests/rejoin.rs index 2c0c23f75af..d6f194b388f 100644 --- a/rs/moq-net/tests/rejoin.rs +++ b/rs/moq-net/tests/rejoin.rs @@ -4,7 +4,7 @@ mod support; use std::time::Duration; -use moq_net::{Hop, Timestamp, Version, group, track}; +use moq_net::{Hop, Timestamp, Version, announce, group, track}; use support::harness::{MockConnectOptions, connect_mock}; /// A millisecond track: the frames written here carry timestamps. @@ -655,13 +655,14 @@ async fn quiet_catalog_survives_cache_expiry(version: Version, takeover: bool) { group.write_frame(Timestamp::ZERO, b"catalog".as_ref()).unwrap(); group.finish().unwrap(); - let upstream = || { + let upstream = |cost| { let mut options = MockConnectOptions::new(version); options.server_publish = Some(publisher.consume()); options.client_subscribe = Some(relay.clone()); + options.cost = Some(cost); connect_mock(options) }; - let mut upstream_session = upstream().await; + let mut upstream_session = upstream(2).await; // Each session gets its own hop, so the relay serves it through its own front. let session = |hop| { @@ -685,10 +686,18 @@ async fn quiet_catalog_survives_cache_expiry(version: Version, takeover: bool) { // the relay takes the track over from the new one. let (mut holder, remote, pair) = session(3).await; assert_eq!(holder.recv_group().await.unwrap().unwrap().sequence, 0, "{version}"); - let replacement = upstream().await; - // An equal route changes no announcement to wait on. The paused clock only - // advances once every task is idle, so this lets its announce land. - moq_net_sim::sleep(Duration::from_millis(100)).await; + // The new connection is cheaper, so the relay reports its route taking over. + let mut follow = relay.consume().follow("bench").unwrap(); + assert!( + matches!(follow.next().await, Some(announce::Event::Start(_))), + "{version}" + ); + let replacement = upstream(1).await; + let event = follow.next().await; + assert!( + matches!(event, Some(announce::Event::Update(_) | announce::Event::Restart(_))), + "{version}: {event:?}" + ); upstream_session = replacement; (holder, remote, pair) } else {