fix(rust_brain): preserve HLC timestamps on snapshot restore#52
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC timestamps on snapshot restore#52cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
restore_from_file() dropped HLC values from snapshots, assigning fresh timestamps instead. After restore, causal successor writes and gossip replays with pre-crash HLCs were rejected with TimestampRegression, causing silent data loss in disaster-recovery and multi-node sync paths. - Add _parse_hlc() for wire/snapshot normalisation - Restore HLC per node and advance global HLC on restore - Pass HLC through bulk_write and gossip.receive() - Reject stale gossip overwrites; skip missing-HLC updates on existing keys 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()dropped HLC timestamps from snapshots, assigning fresh wall-clock HLCs instead. After disaster-recovery restore, causal successor writes and gossip replays with pre-crash HLCs were rejected withTimestampRegression, causing silent data loss in backup/restore and multi-node sync paths.Concrete trigger: Node writes memory with
hlc=(5000, 10, "nodeA"), snapshots to disk, restores after crash. A legitimate successor writehlc=(5000, 11, "nodeA")is rejected because restore assigned a fresh HLC far in the future.Root cause
v0.6.0 added HLC-based monotonic enforcement, but
restore_from_file()never read thehlcfield from snapshot JSON.gossip.receive()andbulk_write()also omitted HLC passthrough.Fix
_parse_hlc()for wire/snapshot normalisation (with legacy fallback fromts_ns)bulk_write()andgossip.receive()Validation
TimestampRegressiontest_restore_preserves_hlc_for_replicationand gossip HLC tests