Skip to content

registrar: every sync poll bumps the snapshot version even when nothing changed, so a reconnecting agent with last_version never matches and always gets the full snapshot #1193

Closed

Description

@bpalermo

Found while fixing #1187 (PR #1188). replaceLocked in registrar/internal/server calls nextVersion() on every sync cycle; in the repro the version reached 3 after two no-op polls. No events are broadcast for a no-op cycle (the diff is empty), so agents do not resync on a tick — but an agent that reconnects with last_version almost never matches the current version after any poll (every --sync-interval, 5 s), so every reconnect pays a full snapshot send. The snapshot-version metric and span attribute also climb once per interval, which makes "version churn" dashboards meaningless.

Fix: bump the version only when the computed diff is non-empty (the content hash or the event list decides), keep nextVersion() for real changes; a unit test that pins "two no-op syncs leave the version unchanged" and "a change bumps it". Then the reconnect fast path (last_version match → no resend) works as designed. Measure on kind: registrar bytes sent per agent reconnect before/after.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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