fix(rust_brain): restore HLC timestamps from snapshots#20
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
restore_from_file() dropped hlc fields added in v0.6.0, assigning fresh timestamps on reload. After restart, gossip/replay writes with pre-crash HLC were rejected (TimestampRegression), causing silent data loss. Also pass hlc through bulk_write when present in row dicts. 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()did not restorehlcfields introduced in v0.6.0. After a restart from snapshot, every node received a fresh Hybrid Logical Clock timestamp instead of its persisted one.Concrete trigger: Agent saves memory via
snapshot_to_file(), restarts, callsrestore_from_file(), then receives gossip/replay events with HLC timestamps from before the crash. Those writes are rejected withTimestampRegression— silent data loss in distributed deployments.Root cause
v0.6.0 added HLC to
MemoryNodeandsnapshot()serialization, butrestore_from_file()was not updated to read thehlcfield. Restored nodes got default-constructed HLC values (current wall clock), making all pre-crash timestamps appear stale.Fix
hlcfrom snapshot JSON inrestore_from_file()_hlc.update()for each restored node so subsequent local writes stay monotonichlcthroughbulk_write()when present in row dictsValidation
test_restore_preserves_hlc_and_accepts_causal_writesintests/test_enterprise_backup.py