[storage/journal/fixed] fix crash recovery for clear_to_size/init_at_size#3809
[storage/journal/fixed] fix crash recovery for clear_to_size/init_at_size#3809roberto-bayardo wants to merge 2 commits into
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
commonware-mcp | c749134 | May 21 2026, 03:03 PM |
33f76f8 to
75bc79b
Compare
Deploying monorepo with
|
| Latest commit: |
c749134
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e7ae18d7.monorepo-eu0.pages.dev |
| Branch Preview URL: | https://fix-init-at-size-crash-recov.monorepo-eu0.pages.dev |
Benchmark resultsTip ✅ PASSED: No benchmark exceeded the regression threshold. Benchmark comparison table
Baseline commit(s): |
There was a problem hiding this comment.
Pull request overview
This PR fixes crash recovery for init_at_size / clear_to_size in the fixed contiguous journal by introducing a write-ahead metadata “clear target” so recovery can complete an interrupted clear/reset to the intended size instead of falling back to blob-derived bounds.
Changes:
- Add a write-ahead
CLEAR_TARGET_KEYmetadata entry and recovery path that completes an interrupted clear/reset oninit(). - Refactor metadata handling with shared helpers (
parse_metadata_u64,stage_pruning_boundary_metadata,complete_clear_to_size) to ensure consistent ordering and crash-safety. - Extend crash-recovery tests to cover additional failure points and mid-section targets.
| .unwrap(); | ||
| metadata.put(PRUNING_BOUNDARY_KEY, 7u64.to_be_bytes().to_vec()); | ||
| metadata.put(CLEAR_TARGET_KEY, 2u64.to_be_bytes().to_vec()); | ||
| metadata.sync().await.unwrap(); |
75bc79b to
7f0c9a9
Compare
|
I think its ok to treat this as 0..0? |
is it always? Feels error prone to say "clear_to_size(42)" and then on restart you suddenly have a 0 size journal? rewind() for example will never leave the journal in a state where it's prior to the attemped rewind point. |
I suppose as long as we document this carefully I could live with it. |
6851713 to
c749134
Compare
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #3809 +/- ##
========================================
Coverage 95.77% 95.77%
========================================
Files 486 486
Lines 200338 200433 +95
Branches 4858 4855 -3
========================================
+ Hits 191872 191973 +101
+ Misses 6834 6831 -3
+ Partials 1632 1629 -3
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary
init_at_size/clear_to_size: a crash after blob clearing but before tail blob creation previously recovered to0..0, losing the target sizeCLEAR_TARGET_KEYmetadata entry so recovery completes the interrupted clear to the intended target instead of falling back to blob stateTest plan
test_fixed_journal_clear_to_size_crash_after_intent_before_blobs— crash after intent, old blobs still presenttest_fixed_journal_clear_to_size_crash_after_mid_section_intent_keeps_old_blob— mid-section target with re-open idempotency check