fix(rust_brain): preserve HLC on snapshot restore and gossip receive#41
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip receive#41cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
restore_from_file() was creating MemoryNode without the snapshot HLC, assigning fresh timestamps. Post-restore causal writes with pre-crash HLC were rejected (TimestampRegression), causing silent data loss after DR. gossip.receive() also ignored HLC, allowing stale remote events to overwrite fresher local state or skip ordering entirely. - Add _parse_hlc() for snapshot/wire normalisation - Restore HLC and advance global clock on snapshot load - Pass HLC through bulk_write, gossip receive with stale rejection - Hold lock during restore and gc_expired - 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
restore_from_file()andgossip.receive()did not preserve or apply Hybrid Logical Clock (HLC) timestamps introduced in v0.6.0.Snapshot restore: After disaster recovery, restored nodes received fresh HLC timestamps instead of their snapshot values. Subsequent causal writes using pre-crash HLC values were rejected with
TimestampRegression, causing silent data loss on the first post-restore write.Gossip sync: Remote events without HLC could overwrite fresher local state, or stale gossip with lower HLC could clobber newer data in distributed deployments.
Root cause
restore_from_file()constructedMemoryNodewithout thehlcfield, defaulting to_hlc.now()gossip.receive()calledremember()without passinghlc,ts_ns, oredgesbulk_write()also dropped HLC from row payloadsFix
_parse_hlc()to normalise HLC from snapshot/wire form (list/tuple) with legacy fallback fromts_ns_hlc.update()restore_from_file()andgc_expired()Validation
pytest tests/test_enterprise_backup.py tests/test_gossip.py tests/test_rust_brain.py— 28 passedtest_restore_preserves_hlc_for_replication, gossip HLC ordering tests