Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions doc/concept/identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ A route resolving a path is chosen in this order:
2. Within one instance, only its highest epoch is eligible, even over a
cheaper route. Readers continue across an epoch change without a seam,
because the timeline continues.
3. Among eligible routes: a route from a peer that has not sent GOAWAY
(a draining peer's routes rank below every other, whatever their preference
or cost, and serve only as a last resort), then the highest priority, which on
3. Among eligible routes: a route that still reaches its publisher, from a
peer that has not sent GOAWAY (an unavailable route, held while the network
may recover a path, and a draining peer's routes rank below every other,
whatever their priority or cost, and serve only as a last resort, so a
restarted publisher's lingering instance never takes the path back), then
the highest priority, which on
moq-lite 07 is the lowest of any link along the route's path, then an
identified chain
over an anonymous one, then the lowest cost, then a broadcast published on
Expand Down
4 changes: 2 additions & 2 deletions drafts/draft-lcurley-moq-lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ The winning tier is the whole answer: a refusal from it never falls through to a
Nor is a refusal retried at another claim of the same prefix.

Within the tier, a claim is ineligible while another claim of the same prefix carries its Instance at a higher Epoch, however cheap it is and whether or not a route reaches it, so a request fails with UNROUTABLE while the newest Epoch is unavailable.
Among the eligible claims, the receiver SHOULD prefer one that is not draining, then the highest priority, then the lowest cost, the claim's cost plus the cost of the route to the node announcing it, then the lowest Rendezvous Hash, and then the most recently received, so a reconnecting publisher is not outranked by the stale session it replaced.
Among the eligible claims, the receiver SHOULD prefer one that is neither draining nor `Unavailable`, then the highest priority, then the lowest cost, the claim's cost plus the cost of the route to the node announcing it, then the lowest Rendezvous Hash, and then the most recently received, so a reconnecting publisher is not outranked by the stale session it replaced.
The Rendezvous Hash is the 64-bit FNV-1a hash, with the standard offset basis `0xCBF29CE484222325` and prime, of the requested path's UTF-8 bytes followed by the claim's Instance.
Every node that knows the same claims ranks them the same, so equal-cost Instances of one prefix share its paths and every relay sends one path to the same Instance.
When choosing which claim to advertise for a prefix, the requested path is the prefix itself.
Expand Down Expand Up @@ -2299,7 +2299,7 @@ A stream that FINs without a GROUP_END carries a closed Group, which may have he
- Replaced Warm and Cold Route Cost with one cost, which each link adds to.
- The Cost parameter must be at least 1.
- Added `Above` to ANNOUNCE_START and ANNOUNCE_UPDATE: how many segments broader than the requested prefix a presented claim is. A claim presented at the requested prefix from above otherwise looked exactly like a claim at the prefix, so a broadcast nested under another's path could lose to the broader claim covering it, depending on the order a relay listed them in. Receivers take a claim to cover its path less its Above.
- Replaced the shortest-path, Hop ID, Instance Hash, and Chain Hash tie-breaks with the claim's drain and priority, its cost, and a Rendezvous Hash of the requested path and the claim's Instance, a standard FNV-1a.
- Replaced the shortest-path, Hop ID, Instance Hash, and Chain Hash tie-breaks with the claim's drain or unavailability and priority, its cost, and a Rendezvous Hash of the requested path and the claim's Instance, a standard FNV-1a.
- Removed the standby-ordering deployment requirements on Route Cost seeds and bounds.

### Tracks {#changelog-07-tracks}
Expand Down
13 changes: 0 additions & 13 deletions quest/m2/cluster-routes/dead-instance-flip.md

This file was deleted.

56 changes: 50 additions & 6 deletions rs/moq-net/src/model/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ impl<'a> Epochs<'a> {
/// neither draining (see [`RouteInfo::draining`]) nor unavailable (see
/// [`RouteInfo::available`]), so a peer that sent a GOAWAY or a held route ranks below
/// every other eligible route and serves only as a last resort. Then the route layer's
/// selected route ahead of its alternates. Then the higher link [`Priority`], so
/// metrics from different operators are never compared. Then an identified chain (no 0) outranks an anonymous one regardless
/// closest way to a broadcast ahead of its others ([`Lane::primary`]). Then the higher
/// link [`Priority`], so metrics from different operators are never compared. Then an identified chain (no 0) outranks an anonymous one regardless
/// of cost, then the cheapest cost, then a broadcast published on this origin (it serves
/// what is here, not a claim that has to ask), then the shortest hop chain, then a hash
/// of the instance and `path`, so every node converges on the same winner, then, among
Expand Down Expand Up @@ -936,9 +936,12 @@ fn route_order(path: &Path, entry: &RouteEntry) -> RouteOrder {
// ranks below a broader one: a stream presents a broader claim at the request,
// where it ties an exact claim for the path.
entry.lane.above,
// The route layer's closest claim ahead of another node's of the same broadcast.
!entry.lane.primary,
entry.draining || !entry.available,
// The route layer's closest way ahead of its others to the same broadcast. Below
// availability, since the route layer marks every way to a broadcast available or
// none: a live instance's other way outranks a dead one held unavailable while a
// route change moves its closest way to another session.
!entry.lane.primary,
// A lite-07 route ranks by the lowest priority of any link on its path.
Reverse(match entry.lane.priority {
Some(priority) => entry.priority.min(Priority::new(priority)),
Expand Down Expand Up @@ -1643,8 +1646,8 @@ struct Horizon {
/// through that node's routes.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub(crate) enum NodeFilter {
/// Every route. Of the route layer's, the primary ones rank first (see [`Lane`]), so
/// a wider covering route serves only while no narrower one does.
/// Every route. Of the route layer's, the most specific claim ranks first and then each
/// broadcast's closest way (see [`Lane`]).
#[default]
Any,
/// Only the routes this node serves itself.
Expand Down Expand Up @@ -10998,6 +11001,47 @@ mod tests {
);
}

/// A restarted publisher's dead instance, held unavailable, never wins back the path from
/// its live replacement while the replacement's closest way moves to another session:
/// the old way is demoted before the session taking over serves the new one.
#[kio::test]
#[cfg(feature = "async")]
async fn a_dead_instance_never_outranks_a_live_one_between_its_ways() {
let producer = origin(1).produce();
let consumer = producer.consume();
let mut announced = consumer.routes();
let route = |instance: &crate::Instance, node, primary, available, cost| {
RouteInfo::new()
.with_instance(instance.clone(), 0)
.with_hops(hops(&[node]))
.with_node(Some(node_id(node)))
.with_lane(Lane {
primary,
priority: Some(0),
..Lane::default()
})
.with_available(available)
.with_cost(cost)
};
let (dead, live) = (crate::Instance::random(), crate::Instance::random());

// The dead instance is cheaper, and still the closest way to its own claim.
let _dead = producer
.forward("room/alice", route(&dead, 10, true, false, 1))
.unwrap();
let way = producer.forward("room/alice", route(&live, 11, true, true, 5)).unwrap();
assert_eq!(announced.expect_next_active("room/alice").await.instance(), &live);

way.update(route(&live, 11, false, true, 5)).unwrap();
assert!(
announced.try_next().is_none(),
"the live instance's demoted way keeps the path"
);
let _pending = consumer.request("room/alice", None);
let request = queued(&way).await;
assert_eq!(request.path().as_str(), "room/alice");
}

/// A draining route ranks below every other eligible one, even on a preferred link
/// against a demoted one, whatever the costs say.
#[kio::test]
Expand Down