fix(rust_brain): preserve HLC on restore and gossip receive#18
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(rust_brain): preserve HLC on restore and gossip receive#18cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
v0.6.0 switched monotonic enforcement from ts_ns to HLC but two call paths were not updated: - restore_from_file() dropped HLC from snapshots, assigning fresh clocks that blocked legitimate post-restore replication and broke causal order. - gossip.receive() omitted HLC, so late-arriving events got a fresh local timestamp and could overwrite newer data on the same key. Restore now round-trips HLC (with ts_ns fallback for legacy snapshots) and advances the process clock. Gossip applies remote HLCs via update_hlc(), rejects stale writes, and skips unordered updates to existing keys when no HLC is present. Regression tests added for both paths. 190 tests pass. 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 (
07a1c75) moved monotonic write enforcement fromts_nsto Hybrid Logical Clock (HLC), but two distributed-data paths were not updated:restore_from_file()dropped HLC — Snapshots include HLC into_dict(), but restore assigned fresh clocks viaMemoryNodedefaults. After disaster-recovery restore, legitimate replication writes with causal successor HLCs were rejected (TimestampRegression), breaking cluster sync. Pre-v0.6.0 snapshots that only hadts_nsare handled via a synthetic HLC fallback.gossip.receive()omitted HLC — Late-arriving gossip events received a fresh local HLC on apply, so stale remote writes could overwrite newer local data on the same key (confirmed with a concrete repro).Root cause
HLC enforcement was added to
remember()without updating snapshot restore or gossip ingestion to propagate timestamps.Fix
restore_from_file()restores HLC from snapshot (list→tuple), falls back tots_ns-derived HLC for legacy snapshots, and advances the process HLC.gossip.receive()callsupdate_hlc(), passeshlc/ts_nstoremember(), rejects stale HLC writes, and skips unordered updates to existing keys when no HLC is present.bulk_write()passes throughhlcwhen provided.Validation
tests/test_enterprise_backup.pyandtests/test_gossip.py