Skip to content

registrar/agent: the watch version is stamped on every event, so a stream truncated mid-snapshot or mid-batch leaves the agent with last_version = V and partial state — a reconnect that matches V skips the resend #1203

Closed

Description

@bpalermo

Found while implementing #1193. FullSnapshotEvents stamps Version on every FULL_SNAPSHOT event and every incremental event in a batch shares one version; the agent's processStream (registry/internal/registrar/registrar.go ~933) sets lastVersion = event.GetVersion() on EVERY event and clears its cache on the first FULL_SNAPSHOT. If the stream ends part-way (a registrar roll cancels the stream ctx with events still queued; handleStreamError keeps lastVersion for GOAWAY/EOF/plain errors — only DataLoss clears it), the agent holds lastVersion = V with partial state, and a reconnect whose last_version matches skips the snapshot: a cleared, partly refilled cache until an unrelated change arrives. Today the per-sync counter bump hides it (the version rarely still matches after 5 s or on the other replica); with a stable version (#1193) it would become the normal case on every registrar roll overlapping churn.

Fix (wire-compatible, no proto change): stamp Version only where a consistent unit ends — on SNAPSHOT_COMPLETE (not FULL_SNAPSHOT / catalog events) and on the last event of each batch as delivered to each watcher (cloned per watcher in Broadcaster.Broadcast, since filtered watchers receive subsets). Old agents already skip empty versions. Cost: a filtered watcher that receives none of a batch keeps its older token and gets a full resend on reconnect — correct, just bandwidth. Being fixed in the #1193 PR as a prerequisite.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions