fix(rust_brain): preserve HLC on snapshot restore and gossip replay - #60
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on snapshot restore and gossip replay#60cursor[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 on writes, but three replication paths did not round-trip HLC timestamps:
restore_from_file()— restored nodes received fresh HLC values instead of snapshot valuesbulk_write()— ignoredhlcfield in row payloadsgossip.receive()— ignoredhlc/ts_nson incoming eventsImpact: After disaster-recovery snapshot restore, valid causal successor writes and gossip replays are rejected with
TimestampRegression, causing silent data loss in distributed deployments.Root cause
HLC enforcement was added to
remember()in v0.6.0, but snapshot restore, bulk import, and gossip apply paths were not updated to preserve or apply stored HLC values.Fix
_parse_hlc()helper for snapshot/wire normalisation (with legacy fallback for pre-v0.6.0 snapshots)restore_from_file(): restorehlc, call_hlc.update()per node, hold_lockduring restorebulk_write(): passhlcfrom row payloadsgossip.receive(): applyhlc/ts_ns, reject stale overwrites, skip missing-HLC updates on existing keysValidation
(wall, 0, uuid)instead of(5000, 10, nodeA); causal write failedtest_enterprise_backup.pyandtest_gossip.py