Skip to content

fix(quic): the fetch-window prune never removes a twin a live stream holds — agent-only restarts no longer drop live twins an hour later (#1073) - #1076

Merged
bpalermo merged 1 commit into
mainfrom
fix/1073-never-prune-held-twins
Sep 30, 2026

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Mechanism

The fetch-window prune (--east-west-quic-pair-fetch-window, 1 h, #1033) removed every persisted pair that had "no on-demand fetch since agent start" and no live subscription. That treated "not fetched" as "not used", which is wrong for a twin the proxy already holds.

  1. A proxy restart (the soak's T0+60 roll) gives the new generation every quic: twin through the wildcard CDS subscription. It never fetches them and holds no ODCDS subscription for them, and carries traffic on them that way.
  2. An agent-only roll (T0+72) makes the proxy re-state those twins on the fresh stream as held-only (initial_resource_versions). The agent serves them because the pairs are persisted, but it never marks them fetched or subscribed.
  3. One window later (23:37Z) every agent logged pruned persisted east-west QUIC pairs with no on-demand fetch since agent start and CDS-removed twins that were still carrying traffic:

#1071's ledger was not the gap: Subscribed already exempted re-subscribed twins. The held-only ones are what got pruned.

Fix: what "in use" means

The agent cannot see traffic. It makes no admin calls, and a held twin is never fetched again. The costs of getting it wrong are asymmetric:

  • a wrongly kept pair is one idle cluster, until its source leaves the node or its destination leaves the dependency set;
  • a wrongly pruned pair means 503s and a possible proxy crash.

So a pair is kept on any evidence of use, ever:

  • A live stream holds an ODCDS subscription for its twin (Ledger.Subscribed, unchanged).
  • The pair is confirmed: fetched on demand, re-subscribed, or its twin re-stated as held on a fresh stream while the agent serves it. The last one is new (SnapshotCache.ConfirmHeldQUICTwins, called from restateTwins). A re-stated twin counts as observed at that moment.
  • The confirmation is persisted in a new field, ObservedQUICPair.demand_confirmed = 4. This is an additive field and the store stays protojson. It covers a node reboot: the fresh proxy holds nothing and uses the twins without ever fetching them, and the pairs still survive the window.

I chose sticky confirmation over a per-stream "held" set. The proxy keeps every twin the agent serves, so a pair re-stated as held once is held by every later generation too. A per-stream holding set would only lose that fact across a hot restart, or when an agent roll is followed by a proxy roll.

The window still drains what no generation vouched for:

A pair pruned wrongly re-fetches on its next request and comes back confirmed, so that can happen at most once per pair.

Invariants kept:

Log line changes:

  • The prune line is now pruned persisted east-west QUIC pairs with no evidence of use: never fetched, subscribed or held by the proxy ….
  • New line: confirmed east-west QUIC pairs the proxy holds without an on-demand subscription: never pruned by the fetch window count=N held_served=S.

Tests

cache/quic_held_prune_test.go:

server/quic_held_prune_test.go:

Existing tests: none deleted. TestQUICDemandPrunesPersistedPairsNotFetchedWithinTheWindow and TestQUICDemandFetchWindowZeroDisablesThePrune now strip demand_confirmed from their store, to model the #1032/pre-#1073 state they were written for. Their assertions are unchanged.

Run locally, all green:

  • bazel test //agent/internal/xds/... //test/mtlspool:all //test/envoy_validate:all
  • bazel test --config=race //agent/internal/xds/cache:all //agent/internal/xds/server:all //agent/internal/xds/quicdemand:all
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...
  • make format-check

Docs

No charts/ change.

Closes #1073

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…holds — agent-only restarts no longer drop live twins an hour later (#1073)

After a proxy restart every quic: twin reaches the new generation through
the wildcard, with no on-demand fetch and no subscription, and carries its
traffic that way. An agent-only roll then re-states those twins on the fresh
stream as held-only, and the fetch-window prune ("no on-demand fetch since
agent start") removed every one of them one window later: ~200 x 503 NC per
burst fleet-wide on the #979 proving soak, and an Envoy SIGBUS on one node
(#1074).

A pair is now kept on any evidence of use, ever: a live stream's on-demand
subscription (the ledger), or a confirmation -- fetched, re-subscribed, or
its twin re-stated as HELD on a fresh stream while the agent serves it
(ConfirmHeldQUICTwins). The confirmation is persisted
(ObservedQUICPair.demand_confirmed), so a node reboot, where the fresh proxy
uses twins it never fetches, does not prune them either. The window still
drains pairs no generation vouched for (the #1032 fan-out, pre-#1073 pairs
the proxy neither holds nor fetches).

Closes #1073

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant