fix(rust_brain): preserve HLC on snapshot restore and gossip receive#26
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip receive#26cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
restore_from_file dropped hlc fields added in v0.6.0, assigning fresh timestamps on restore. Post-crash causal writes and gossip replays with pre-crash HLC were rejected (silent data loss), while gossip events without HLC could overwrite fresher data. - Add _parse_hlc() for snapshot/wire normalisation with legacy fallback - restore_from_file: restore hlc and advance global _hlc per node - bulk_write: pass through hlc from row payloads - gossip.receive: apply hlc, reject stale updates, skip missing-hlc overwrites on existing keys - Tests: snapshot HLC round-trip, gossip stale/new/missing-hlc cases 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
Critical data-loss bug in v0.6.0 HLC enforcement.
After
restore_from_file(), restored nodes received fresh HLC timestamps instead of the values stored in the snapshot. Causal successor writes from the original writer (e.g. gossip replay or post-crash replication withhlc=(5000, 11, "nodeA")) were rejected as stale, causing silent data loss. Separately,gossip.receive()ignored HLC entirely, allowing gossip events without HLC to overwrite fresher local data.Concrete trigger: snapshot → restore →
remember(key, v2, hlc=successor)raisesTimestampRegressionand the update is dropped.Root cause
restore_from_file()constructedMemoryNodewithout restoring thehlcfield from snapshot JSON.gossip.receive()calledremember()without passinghlc,ts_ns, oredges.bulk_write()did not pass throughhlcfrom row payloads.Fix
_parse_hlc()for snapshot/wire normalization with legacyts_nsfallback.restore_from_file(): restorehlcper node and advance global_hlc.bulk_write(): pass throughhlcwhen present.gossip.receive(): applyhlc, reject stale updates, skip missing-HLC overwrites on existing keys.Validation
test_restore_preserves_hlc_for_replication, gossip stale/new/missing-hlc cases.