fix(rust_brain): preserve HLC on snapshot restore and gossip replay - #75
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip replay#75cursor[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 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>
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(),bulk_write(), andgossip.receive()did not preserve Hybrid Logical Clock (HLC) timestamps introduced in v0.6.0. After a snapshot restore, the store assigns fresh HLC values instead of the saved ones. Any subsequent write with a causally valid pre-crash HLC (gossip replay, bulk import, or peer sync) raisesTimestampRegressionand is silently dropped — data loss after disaster recovery.Concrete trigger: Snapshot a node with HLC
(5000, 10, "nodeA"), restore, then apply a causally later write with HLC(5000, 11, "nodeA"). The write is rejected because restore assigned a fresh wall-clock HLC.Root cause
restore_from_file()createdMemoryNodewithout reading thehlcfield from the snapshot, defaulting to_hlc.now().bulk_write()did not passhlcfrom row payloads.gossip.receive()did not apply or update HLC on incoming events.Fix
_parse_hlc()helper for wire/snapshot normalization.restore_from_file(): restore stored HLC, update global clock via_hlc.update(), hold lock during mutation.bulk_write(): round-trip HLC from row payloads.gossip.receive(): apply HLC, reject stale updates, skip missing-HLC overwrites on existing keys.Validation
test_hlc_snapshot_gossip.py,test_enterprise_backup.py,test_gossip.py,test_rust_brain.py.