fix: make journal stream initialization fail closed - #52
Merged
Conversation
Signed-off-by: Guocheng(Eric) Song <132118805+feichai0017@users.noreply.github.com>
Signed-off-by: Guocheng(Eric) Song <132118805+feichai0017@users.noreply.github.com>
Signed-off-by: Guocheng(Eric) Song <132118805+feichai0017@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.
What changed
Holt 0.9.0 could persist the first journal anchor slot, fail while writing the second slot, and then accept ordinary writes. A later reopen treated the stream as initialized even though those mutations had no recovery envelope.
This change fences ordinary writes before the first anchor slot can become durable. An interrupted initialization remains incomplete and accepts only an exact retry with the same genesis anchor. State reads, scans, and attached writes fail until the retry repairs both slots. Open, replay, and recovery scans reject an ordinary logical record after an initialized attached-stream anchor.
Attached submission now carries encoder-sealed bytes and its owned envelope into group commit. The commit path no longer decodes and copies the record before queueing it. Replay and recovery scans still decode records and verify CRCs. The branch also adds a permanent journal-path benchmark and prepares version 0.9.1.
Test plan
cargo fmt --all -- --checkcargo build --workspace --all-targets --all-features --lockedcargo test --workspace --all-features --lib --tests --examples --lockedcargo test --workspace --all-features --doc --lockednormal/db-normalsoak runscargo publish --dry-run --lockedRegression tests cover failures before zero or one durable anchor slots, same-genesis repair, different-genesis rejection, and a checkpoint during incomplete initialization. They also cover mixed
InsertandBatchrecords across open, replay, streaming validation, and recovery scans. Codec tests compare sealed records with the generic encoder and exercise varied payloads and operations.The local host lacks rustup/nightly,
cargo-deny,cargo-llvm-cov, and the Linux io_uring environment. GitHub Actions remains responsible for those platform, fuzz, coverage, and dependency-policy gates.Compatibility and recovery boundary
Holt 0.9.1 keeps the format-4 WAL, public journal API, record bytes, CRC replay checks, and checkpoint protocol. Existing 0.9.0 stores need no format migration.
If Holt 0.9.0 returned an initialization error and then accepted ordinary writes, 0.9.1 rejects mixed records that remain in the WAL. If 0.9.0 checkpointed those writes, the WAL suffix is gone. Holt cannot detect or reconstruct that recovery gap. Rebuild such a store from authoritative application state before using the attached stream.
Performance evidence
A controlled same-host A/B found no measurable ordinary-write regression from the atomic fence. Median latency changed by -1.26% for puts and -0.12% for the mixed workload. Both confidence intervals crossed zero.
Removing the submission-time decode reduced median
sync: falseattached-commit latency by 12.81% with 128-byte payloads and 27.50% with 4 KiB payloads. Mediansync: truelatency changed by -0.17%, where forced sync dominates.A fresh run of the permanent async benchmark measured ordinary commits at 758.92 to 827.72 ns. Attached commits measured 838.19 to 855.25 ns at 128 bytes and 1.8607 to 1.9227 us at 4 KiB.
Related
Follow-up to #51. This maintainer-directed Holt 0.9.1 hotfix has no linked issue.