core/storage: Only mark WAL initialized after a successful header sync#7379
Open
penberg wants to merge 1 commit into
Open
core/storage: Only mark WAL initialized after a successful header sync#7379penberg wants to merge 1 commit into
penberg wants to merge 1 commit into
Conversation
prepare_wal_finish's sync completion callback ignored its result and called mark_initialized() unconditionally. Because the completion machinery runs the sync callback on failure as well as success, a failed header fsync still flipped the in-memory initialized flag to true. After that, prepare_wal_start short-circuits and prepare_wal_header returns None, so the header is never re-issued before the next append, leaving the in-memory state claiming durability the on-disk header never reached. Guard the mark_initialized() call on res.is_ok() so a failed sync leaves the WAL uninitialized and the header is rewritten on the next append. Found by Aristo.
Merging this PR will improve performance by 19.14%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | format_float_neg_infinity |
1.2 µs | 1 µs | +19.9% |
| ⚡ | Simulation | format_float_infinity |
1.3 µs | 1.1 µs | +19.33% |
| ⚡ | Simulation | format_float_zero |
1,136.4 ns | 961.4 ns | +18.2% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing workspace-6-2 (6fd58f4) with main (d001d54)
Footnotes
-
105 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
pereman2
approved these changes
Jun 8, 2026
avinassh
approved these changes
Jun 8, 2026
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.
prepare_wal_finish's sync completion callback ignored its result and
called mark_initialized() unconditionally. Because the completion
machinery runs the sync callback on failure as well as success, a failed
header fsync still flipped the in-memory initialized flag to true. After
that, prepare_wal_start short-circuits and prepare_wal_header returns
None, so the header is never re-issued before the next append, leaving
the in-memory state claiming durability the on-disk header never reached.
Guard the mark_initialized() call on res.is_ok() so a failed sync leaves
the WAL uninitialized and the header is rewritten on the next append.
Found by Aristo.