Skip to content

fix(rust_brain): preserve HLC on snapshot restore and gossip replay - #76

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-0f05
Draft

fix(rust_brain): preserve HLC on snapshot restore and gossip replay#76
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-0f05

Conversation

@cursor

@cursor cursor Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

restore_from_file() assigned fresh HLC timestamps instead of reading them from the snapshot. After disaster-recovery restore, causally valid writes (gossip replay, bulk_write, post-restore updates) raised TimestampRegression and were silently dropped — data loss in distributed deployments.

Root cause

HLC timestamps were added in v0.6.0 and serialized in snapshots, but restore/gossip/bulk_write paths never parsed or applied them. Restored nodes got fresh wall-clock HLCs that were always "newer" than legitimate causal successors from peers.

Fix

  • Add _parse_hlc() helper for snapshot/wire normalization
  • restore_from_file(): restore HLC per node, update global HLC, hold lock during restore
  • bulk_write(): pass through HLC from row payloads
  • gossip.receive(): apply HLC, reject stale updates, skip HLC-less overwrites on existing keys

Validation

  • Reproduced pre-fix: restore assigned fresh HLC; causal successor write failed with TimestampRegression
  • 29 targeted tests pass: test_hlc_snapshot_gossip.py, test_enterprise_backup.py, test_gossip.py, test_rust_brain.py
Open in Web View Automation 

restore_from_file() assigned fresh HLC timestamps instead of reading
them from the snapshot, causing causally valid writes (gossip replay,
bulk_write, post-restore updates) to raise TimestampRegression and
silently drop data. Also fix bulk_write and gossip.receive() to
round-trip HLC timestamps.

Co-authored-by: Daniel <DJLougen@users.noreply.github.com>
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.

1 participant