Skip to content

core/storage: Only mark WAL initialized after a successful header sync#7379

Open
penberg wants to merge 1 commit into
mainfrom
workspace-6-2
Open

core/storage: Only mark WAL initialized after a successful header sync#7379
penberg wants to merge 1 commit into
mainfrom
workspace-6-2

Conversation

@penberg
Copy link
Copy Markdown
Collaborator

@penberg penberg commented Jun 5, 2026

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.

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.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 5, 2026

Merging this PR will improve performance by 19.14%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 632 untouched benchmarks
⏩ 105 skipped benchmarks1

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants