fix(rust_brain): preserve HLC timestamps on snapshot restore and gossip - #61
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC timestamps on snapshot restore and gossip#61cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
restore_from_file() assigned fresh HLC timestamps instead of preserving snapshot values, causing TimestampRegression on legitimate post-restore writes and silent gossip data loss. Also pass HLC through bulk_write and gossip.receive() with stale-event rejection. 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()did not preserve Hybrid Logical Clock (HLC) timestamps from snapshots. After disaster-recovery restore, nodes received fresh(wall, 0, uuid)HLCs instead of their saved causal timestamps. Legitimate post-restore writes and gossip replays with pre-crash HLCs raisedTimestampRegressionand were silently dropped — causing data loss in distributed deployments after backup restore.gossip.receive()also ignored incoming HLCs, allowing stale events to overwrite fresher data or rejecting valid causal updates.Root cause
v0.6.0 added HLC-based monotonic ordering but
restore_from_file(),bulk_write(), andgossip.receive()were not updated to preserve/pass HLC values.Fix
_parse_hlc()helper for wire/snapshot normalizationrestore_from_file(): restore HLC from snapshot, update global HLC, hold lock during restorebulk_write(): pass throughhlcfield from rowsgossip.receive(): apply incoming HLC, reject stale updates, skip missing-HLC updates on existing keysValidation
TimestampRegressiontests/test_enterprise_backup.py::test_restore_preserves_hlc_for_replication(new)tests/test_gossip.py: 3 new HLC ordering tests