Skip to content

fix(registrar): hand watchers the version on no-op revisions (#1241) - #1267

Merged
bpalermo merged 2 commits into
fix/1239-watch-filter-resumefrom
fix/1241-version-markers
Oct 5, 2026
Merged

bpalermo merged 2 commits into
fix/1239-watch-filter-resumefrom
fix/1241-version-markers

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Stacked on the #1239 PR.

Problem

store_revision − aether_agent_registry_last_version grew whenever the registrar's version moved and no batch reached the agent. That happens in two cases:

  • a store revision that changes no contents, for example a write-behind flush landing in etcd after the RPC already applied the change (<rev>+<h> → <rev'>.<h>);
  • a change to a service outside a filtered agent's watch filter.

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 a SNAPSHOT_COMPLETE carrying 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.

The agent adopts a post-initial SNAPSHOT_COMPLETE's version as its token and gauge without waking its consumers.

Skew

  • Old agent, new registrar: an old agent handles a post-initial SNAPSHOT_COMPLETE like 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 its applyEvent signals 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.
  • New agent, old registrar: no markers arrive, and the gauge is an upper bound as before.

The runbook says so and says to alert on the lag only once both sides are on this change. content_hash agreement 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=4 on the two touched go_test targets, plus the dependent cmd/services tests. Lint with fail_on_violation and make format-check are clean.
  • Not verified on kind: the kind harness runs the kubernetes backend, where last_version is 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, MarkVersion would certify a misordered cache as current for good. The publisher fix is in #1266, the bottom of the stack, so this marker lands on an ordered publisher. This PR adds TestMarkVersion_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. With Publish back 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

bpalermo and others added 2 commits October 5, 2026 13:42
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
bpalermo force-pushed the fix/1241-version-markers branch from 53fda37 to 79c4cf5 Compare October 5, 2026 16:42
@bpalermo
bpalermo merged commit 28b2680 into main Oct 5, 2026
47 checks passed
@bpalermo
bpalermo deleted the fix/1241-version-markers branch October 5, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metrics: aether_agent_registry_last_version lags the store on no-op revisions — unusable as a propagation-lag signal

1 participant