Repository navigation
feat(persistence): coordinated AOF background rewrite engine and atomic cutover - #7
Merged
Merged
Conversation
…ic cutover - Capture consistent base snapshot under commit fence (with_commit_fence) covering KV entries, expiration deadlines, and HNSW/Flat vector graphs - Buffer concurrent mutations in bounded delta queue (64 MiB / 65,536 records); delta exhaustion cleanly cancels rewrite via AtomicBool without impacting active writes - Execute atomic cutover on writer thread: flush deltas, sync replacement file, rename over active journal path, swap descriptor while retaining lock, and fsync parent directory - Handle directory sync failure after rename with InstallError::AfterRename, halting writes via dispatch.fail() to prevent filesystem divergence - Support self-contained log recovery via scan_base and ChecksummedReader with IEEE 802.3 CRC32 verification before state hydration - Verify dev and inode in open_locked to guard against replacement races - Re-enable live BGREWRITEAOF command returning +Background append only file rewriting started - Fully resolves Finding C in ADR 6 Step 7, completing all ADR 6 milestones
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.
Summary
This PR delivers Finding C (Step 7) of Architecture Decision Record 6 (
improvements/improvement-6-design-decision.md), completing the entire implementation of ADR 6 with a production-grade, crash-resilient background rewrite engine for KacheDB.Key Deliverables
durability::with_commit_fence) incrates/kachedb-server/src/snapshot.rs, anchoring KV table entries, expiration deadlines, and HNSW/Flat vector graphs at an exact log sequence..rewrite-<hex>.tmp) with strict0o600permissions.BaseHeader.DELTA_BYTES = 64 MiB,DELTA_RECORDS = 65,536).AtomicBoolwithout impacting active writes.*active = replacement.file).InstallError::AfterRename) transitions todispatch.fail()to halt writes and prevent filesystem divergence.crates/kachedb-server/src/aof_recovery.rsdetects embedded base (BASE_KIND) viascan_base.ChecksummedReadervalidating IEEE 802.3 CRC32 before hydrating SwissTable and vector indices.BGREWRITEAOFCommand:BGREWRITEAOFreceive+Background append only file rewriting started.Verification
cargo fmt --all -- --check: PASS (0 diffs)cargo clippy --workspace --all-targets --all-features -- -D warnings: PASS (0 warnings across all 11 crates)cargo test -p kachedb-server -- aof_rewrite: PASS (6/6 tests passed in 0.13s)cargo test -p kachedb-server --test durability background_rewrite: PASS (passed in 1.75s)cargo test --workspace: PASS (100% pass across all unit, doc, and integration tests)prvStaff Review: APPROVE (11/11 dimensions passed)