fix(rust_brain): preserve HLC on snapshot restore and gossip replay#44
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip replay#44cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
restore_from_file() dropped HLC timestamps from snapshots, assigning fresh wall-clock HLCs instead. Post-restore causal writes and gossip replays with legitimate successor timestamps were rejected as TimestampRegression, causing silent data loss in disaster-recovery and multi-node deployments. - Add _parse_hlc() for snapshot/wire HLC normalisation - Restore HLC and advance global clock on snapshot load - Pass HLC/ts_ns through gossip.receive() with stale-update rejection - Pass HLC through bulk_write; lock gc_expired during iteration - Add regression tests for restore round-trip and gossip ordering Co-authored-by: Daniel <DJLougen@users.noreply.github.com>
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.
Bug and impact
restore_from_file()andgossip.receive()did not preserve or apply Hybrid Logical Clock (HLC) timestamps introduced in v0.6.0. After a snapshot restore, restored nodes received fresh wall-clock HLCs instead of their stored causal timestamps. Legitimate post-restore writes and gossip replays with successor HLCs were rejected asTimestampRegression, causing silent data loss in disaster-recovery and multi-node deployments.Concrete trigger: Write key with
hlc=(5000, 10, "nodeA")→ snapshot → restore → attempt causal successorhlc=(5001, 11, "nodeA")→TimestampRegressionbecause restored node has fresh wall-clock HLC ~1.7e18.Root cause
restore_from_file()constructedMemoryNodewithout readinghlcfrom snapshot JSON (defaulted to_hlc.now())gossip.receive()calledremember()without passinghlc/ts_nsbulk_write()also omitted HLC passthroughFix
_parse_hlc()for snapshot/wire HLC normalisation (with legacy fallback fromts_ns)_hlc.update()gossip.receive()with stale-update rejection and skip missing-HLC updates on existing keysbulk_write(); lockgc_expired()during iterationValidation
TimestampRegression)test_restore_preserves_hlc_for_replication, gossip HLC ordering tests