fix(rust_brain): preserve HLC on snapshot restore and gossip replay - #70
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip replay#70cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
v0.6.0 added HybridLogicalClock enforcement but restore_from_file(), bulk_write(), and gossip.receive() did not round-trip HLC timestamps. After disaster-recovery restore, nodes received fresh HLC values, causing TimestampRegression on valid causal successor writes and silent rejection of gossiped updates. - Add _parse_hlc() for snapshot/wire normalisation with legacy fallback - restore_from_file: restore hlc, update global clock, hold lock - bulk_write: pass hlc from row payloads - gossip.receive: apply hlc, reject stale overwrites, skip missing-hlc updates - 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
v0.6.0 added Hybrid Logical Clock (HLC) monotonic enforcement, but
restore_from_file(),bulk_write(), andgossip.receive()did not round-trip HLC timestamps.Concrete trigger: After disaster-recovery snapshot restore, restored nodes received fresh HLC values instead of their snapshot HLCs. Valid causal successor writes (e.g.
hlc=(5000, 11, "nodeA")after restore of(5000, 10, "nodeA")) raisedTimestampRegressionand were rejected — silent data loss in replication/gossip paths.Root cause
restore_from_file()createdMemoryNodewithout passinghlc, defaulting to_hlc.now()bulk_write()omittedhlcfrom row payloadsgossip.receive()did not passhlc/ts_nsand could not reject stale overwritesFix
_parse_hlc()for snapshot/wire normalisation with legacy fallbackrestore_from_file: restore HLC, update global clock, hold lock during mutationbulk_write: passhlcfrom row payloadsgossip.receive: apply HLC, reject stale overwrites, skip missing-HLC updates on existing keysValidation
pytest tests/test_enterprise_backup.py tests/test_gossip.py tests/test_rust_brain.py— 27 passed