Repository navigation
fix(registrar): hand watchers the version on no-op revisions (#1241) - #1267
Merged
Merged
Conversation
bpalermo
marked this pull request as ready for review
October 5, 2026 14:30
bpalermo
force-pushed
the
fix/1241-version-markers
branch
from
October 5, 2026 14:51
467dd65 to
70dec57
Compare
This was referenced Oct 5, 2026
bpalermo
force-pushed
the
fix/1241-version-markers
branch
from
October 5, 2026 15:52
70dec57 to
53fda37
Compare
bpalermo
force-pushed
the
fix/1241-version-markers
branch
from
October 5, 2026 15:52
70dec57 to
53fda37
Compare
store_revision - aether_agent_registry_last_version grew on store revisions that changed no content (a write-behind flush landing in etcd after the RPC already applied it) and on changes outside a filtered agent's watch filter: nothing was broadcast to the agent, so its resume token and gauge stayed behind a current cache until an unrelated change. On the 2.4.5 soak the edge sat 81 revisions behind for 23 minutes with nothing stale. Each sync cycle now ends with Broadcaster.MarkVersion: every watcher whose channel was not last given the snapshot's current version receives a version-only SNAPSHOT_COMPLETE carrying it. It runs with publishMu held for writing, so no publication is between its snapshot mutation and its broadcast and every batch the version includes is already ahead of the marker on every channel (the #1203/#1205 rule). The sync cycle is the throttle; a full channel skips its marker and is retried next cycle, never force-resynced. The agent adopts a post-initial SNAPSHOT_COMPLETE's version without waking its consumers. An agent older than this treats the marker as it treats any later SNAPSHOT_COMPLETE: it adopts the version and runs one redundant refresh. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…1241) Adds the #1239 review's F2 scenario with the marker. A held register and an unregister of the same endpoint arrive, then a no-op revision and MarkVersion. Without serialized publications the watcher kept the removed endpoint under the older version, and the marker certified that cache as current. With them, every version the watcher is handed, the marker's included, names what it holds. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
force-pushed
the
fix/1241-version-markers
branch
from
October 5, 2026 16:42
53fda37 to
79c4cf5
Compare
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.
Stacked on the #1239 PR.
Problem
store_revision − aether_agent_registry_last_versiongrew whenever the registrar's version moved and no batch reached the agent. That happens in two cases:<rev>+<h>→<rev'>.<h>);The agent's cache was current in both cases, but its gauge and resume token stayed behind until an unrelated change. On the 2.4.5 soak the edge sat 81 revisions behind for 23 minutes, so the lag metric could not be alerted on.
Fix: the preferred option (a version-only marker)
At the end of each sync cycle the syncer calls
Broadcaster.MarkVersion. Every watcher whose channel was not last given the snapshot's current version receives aSNAPSHOT_COMPLETEcarrying only that version. The watcher's last-sent version is tracked per watcher: its initial exchange, its last versioned batch event, or its last marker.MarkVersionholdspublishMufor writing, so no publication is between its snapshot mutation and its broadcast. Every batch the current version includes is therefore already on every channel ahead of the marker, and a watcher that overflowed on one of those batches has already been closed. A filtered watcher holds the version for every service in its filter, which is what every token means.TestMarkVersion_WaitsForAnInFlightPublicationis the negative: with a read lock instead of the write lock it fails ("MarkVersion ran while a publication was between its mutation and its broadcast").<rev>.<hash>,<rev>+<hash>andhash:<hash>. The marker carries whateverSnapshot.Version()is. On the kubernetes backend (hash:) only out-of-filter changes produce markers, and the agent gauge is still not recorded there.aether_registrar_broadcast_events_total{aether_event_type="EVENT_TYPE_SNAPSHOT_COMPLETE"}counts the markers, and the sync span carriesaether.sync.version_markers.The agent adopts a post-initial
SNAPSHOT_COMPLETE's version as its token and gauge without waking its consumers.Skew
SNAPSHOT_COMPLETElike a later marker. Its catalog replay is already nil, so there is no catalog swap and readiness is unchanged. It adopts the version, which is correct, and itsapplyEventsignals one debounced xDS refresh from an unchanged cache. That is the only cost, paid once per version-moving sync cycle until the agent DaemonSet rolls.The runbook says so and says to alert on the lag only once both sides are on this change.
content_hashagreement is alertable regardless.Tests
registrar/internal/server/version_marker_test.go: a no-op revision marks full and filtered watchers once, and a second idle sync marks none; an out-of-filter change marks only the non-consumer; the in-flight-publication negative; a full channel is skipped without closing the watcher and retried later.registry/internal/registrar/version_marker_test.go: the marker advances the token, and leaves the cache, catalog and readiness untouched with no change signal.bazel test,--config=race --runs_per_test=4on the two touchedgo_testtargets, plus the dependentcmd/servicestests. Lint withfail_on_violationandmake format-checkare clean.last_versionis not exported. Only the etcd-backend gauge behaviour is covered, by the unit tests above.Runbook: the "Stored vs in place vs applied" section now treats the agent lag line as settling to 0 per sync cycle, and its skew note covers older agents and registrars.
Review findings fixed
The review's F2 finding was that with concurrent publications,
MarkVersionwould certify a misordered cache ascurrentfor good. The publisher fix is in #1266, the bottom of the stack, so this marker lands on an ordered publisher. This PR addsTestMarkVersion_CertifiesOnlyAnOrderedCache: a held register and a same-endpoint unregister, then a no-op revision and the marker. At every version it hands out, the marker's included, the watcher must hold what that version names. WithPublishback on a read lock it fails ("version 6.… reached a cache that does not hold its contents").Closes #1241
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr