Repository navigation
fix(quic): track twin subscriptions per proxy generation so overlapping ADS streams after an agent restart can't leave phantom dormant pairs (#1052) - #1071
Merged
Conversation
…ng ADS streams after an agent restart can't leave phantom dormant pairs (#1052) The QUIC twin ledger kept one process-wide subscription set that every fresh xDS stream replaced. After an agent restart that lands mid hot restart, two proxy generations reconnect: on rev248 w03 the child's stream (naming nothing) pruned the dormant pairs, and the draining parent's stream 11 s later re-subscribed them and they were parked dormant again, outliving the parent. quicdemand.Ledger now holds subscriptions per xDS stream (the stream is the proxy generation: one Envoy process speaks one ADS stream and the Node carries no restart epoch). A dormant pair is kept only while a live stream holds it: Restate records a fresh stream's re-statement for that stream alone, and the new Close drops an ended stream's holdings when another stream is live (pruning dormant pairs nobody holds). The last live stream ending orphans its holdings until the next re-statement, as before. The observer passes the stream ID through ObserveQUICTwin / RestateQUICSubscriptions / ResumeQUICSubscriptions and calls the new CloseQUICStream on stream close. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 29, 2026
… ledger, #1072) odcds.go: main's stream-scoped observeQUICTwin(streamID, name) with #979's dependency-set wording. The new server/quic_generation_test.go fixture puts demo/echo in the dependency set (RestoreDependency) instead of allow-listing it; the soak new-SA step's wording notes both destinations are QUIC-eligible since #979. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 30, 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.
Mechanism
quicdemand.Ledgerkept one process-wide set of on-demand (ODCDS) twin subscriptions, and every fresh xDS stream's first CDS request replaced it (Restate). A dormant pair the new set did not name was pruned; a re-subscribed, unservable pair was parked dormant (recordQUICPair→Park).After an agent restart that lands mid proxy hot restart, two proxy generations reconnect, each on its own fresh stream. On rev248 main-worker-03:
15:39:16Zthe child's stream named nothing.Restate(∅)pruned the persisted dormant pairs.15:39:27Zthe draining parent's stream re-subscribed them. They were parked dormant again.That breaks the premise of the republish-on-return path (#1038: "the proxy still holds their on-demand subscriptions, so the twin is pushed with no request"). #979 (QUIC unconditional) multiplies pairs, so this has to be right before the proving soak.
Generation identity: the xDS stream ID
Nodedoes not tell two generations apart. Both get the same--service-node/--service-cluster/--service-zoneand the same bootstrap.--restart-epochis not visible over xDS. Node metadata carries no epoch.streamID(given toOnStreamDeltaRequestandOnDeltaStreamClosed) is the proxy generation as the agent sees it.Fix
quicdemand.Ledgernow holds subscriptions per stream (streams map[int64]set), plus anorphanedset:Subscribe(stream, k)recordskon that stream.Restate(stream, resubscribed)replaces that stream's set and clearsorphaned. It prunes only the dormant pairs that no live stream holds. If the parent still holds a pair, the child's empty re-statement no longer prunes it.Close(stream):orphaneduntil the next fresh stream re-states them. That is the pre-QUIC twins: after an agent restart the first fresh proxy stream re-subscribes nothing and prunes the dormant pairs; a later stream parks them dormant again — the ledger can hold dormant pairs the current proxy generation has no subscription for #1052 single-stream behaviour.Subscribed(k)returns true if any live stream or the orphaned set holdsk.Retireand the fetch-window prune use it.Cache:
ObserveQUICTwin,RestateQUICSubscriptions,ResumeQUICSubscriptionsandrecordQUICPairtake the stream ID.CloseQUICStream(ctx, streamID)marks the persisted set dirty and logspruned dormant east-west QUIC pairs: the proxy generation that held their on-demand subscriptions ended its stream while a newer one is live stream=… count=….Observer: passes
streamIDthrough, andonDeltaStreamClosedcallsCloseQUICStream.Invariants kept:
dormant_quic_pairs, field 3). No proto change.Tests
quicdemand/ledger_test.go:TestLedgerOverlappingGenerationsAfterAgentRestart: persisted dormant pairs reloaded, then two overlapping streams new→old (the rev248 order) and old→new, then the old stream ends. Also a case where the child's own later subscription survives the parent's exit.TestLedgerLastStreamEndOrphansUntilRestateTestLedgerStreamResetWhileAnotherGenerationIsLivecache/quic_generation_test.go:TestQUICDormantPairsOverlappingGenerationsNewThenOldand…OldThenNew: an agent restart with a persisted-ledger reload, both stream orders, and the parent's stream end. They assert no phantom dormant pair in memory or inobserved-upstreams.json, and no republish on the source's return.TestQUICDormantPairRepublishedForTheGenerationThatHoldsItTestQUICLastStreamEndKeepsDormantUntilTheNextRestateserver/quic_generation_test.go:TestOnDemandObserver_OverlappingProxyGenerationsAfterAgentRestart: the real observer callbacks and a real cache, both orders. Agent 1 persists the pairs, agent 2 reloads them, two fresh streams arrive, the parent's stream closes, and agent 3 reloads the store and finds no phantom.TestOnDemandObserver_ChildFirstUseSurvivesParentExittestQUICStream).TestLedgerTestQUICDormantPairsPrunedOnProxyGenerationChangeTestOnDemandObserver_FreshStreamRestatesSubscriptionsForDormantPairs//test/mtlspooluses the newRestate/Subscribesignatures.Run locally, all green:
bazel test //agent/internal/xds/...(8/8)bazel test --config=race //agent/internal/xds/cache:all //agent/internal/xds/server:all //agent/internal/xds/quicdemand:allbazel test //test/mtlspool:mtlspool_test(real Envoy)bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...make format-checkDocs
docs/runbook.md, east-west QUIC "Pruning": pairs are held per stream, the two prune log lines, and the #1052 failure shape.No
charts/change.Closes #1052
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr