fix(rust_brain): preserve HLC on snapshot restore and gossip receive#34
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip receive#34cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
After v0.6.0 added HLC monotonic enforcement, restore_from_file() and gossip.receive() did not preserve or apply HLC timestamps. Snapshot restore assigned fresh HLCs, causing legitimate causal successor writes to raise TimestampRegression (silent data loss). Gossip without HLC could overwrite fresher local data. - Add _parse_hlc() for snapshot/wire normalization - Restore HLC and update global clock on snapshot restore - Pass HLC through bulk_write and gossip receive with stale 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
After v0.6.0 added HLC monotonic enforcement,
restore_from_file()andgossip.receive()did not preserve or apply HLC timestamps from snapshots or peer events.Concrete trigger: Snapshot a node with
hlc=(5000, 10, "nodeA"), restore, then apply a causal successor write withhlc=(5000, 11, "nodeA"). Restore assigns a fresh wall-clock HLC, so the legitimate successor write raisesTimestampRegression— silent data loss on disaster recovery and replication.Gossip without HLC could also overwrite fresher local data.
Root cause
restore_from_file()rebuiltMemoryNodewithout the snapshothlcfield (default factory assigned a new HLC).bulk_write()andgossip.receive()did not pass through HLC from incoming rows/events.Fix
_parse_hlc()for snapshot/wire normalization (with legacy fallback fromts_ns)._hlc.update()per restored node.bulk_writeandgossip.receive(); reject stale gossip updates and skip missing-HLC overwrites on existing keys.Validation
test_restore_preserves_hlc_for_replication, gossip HLC tests.pytest tests/test_enterprise_backup.py::test_restore_preserves_hlc_for_replication tests/test_gossip.py tests/test_rust_brain.py tests/test_rust_brain_concurrency.py— 30 passed.