fix(rust_brain): preserve HLC on snapshot restore and gossip receive - #58
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip receive#58cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
restore_from_file() dropped hlc from snapshots and assigned fresh _hlc.now() timestamps, causing TimestampRegression on causal successor writes and silent gossip data loss after disaster recovery. - Add _parse_hlc() for wire/snapshot normalisation - Restore hlc field and advance global HLC during restore - Pass hlc through bulk_write and gossip.receive - 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 Hybrid Logical Clock (HLC) timestamps introduced in v0.6.0. After snapshot restore, nodes received fresh_hlc.now()timestamps instead of their saved HLCs. Any causal successor write or gossip replay with the pre-crash HLC raisedTimestampRegression— causing silent data loss after disaster recovery and cross-node replication.Concrete trigger: Snapshot a node with
hlc=(5000, 10, "nodeA"), restore, then apply successor writehlc=(5000, 11, "nodeA")→TimestampRegressionbecause restored HLC was(wall, 0, uuid).Root cause
restore_from_file()createdMemoryNodewithout reading thehlcfield from snapshot JSON (defaults to_hlc.now()).gossip.receive()calledremember()without passinghlcorts_nsfrom gossip events.bulk_write()also omittedhlcpassthrough.Fix
_parse_hlc()for wire/snapshot normalisation (with legacyts_nsfallback).hlcfield and advance global HLC via_hlc.update()during restore (under lock).hlcthroughbulk_writeandgossip.receivewith stale-event rejection.Validation
test_restore_preserves_hlc_for_replication, gossip HLC ordering tests.