-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Checkpoints
-
None
-
Storage Engines - Persistence
-
653.592
-
None
-
None
Lines 729-825 of _ckpt_process (inside the live_lock) handle the core checkpoint deletion logic: freeing blocks, merging extent lists from deleted checkpoints into subsequent checkpoints, and finding blocks for reuse. This is the most complex section with nested loops and multiple conditional branches. Extracting it into a focused helper will significantly reduce the cyclomatic complexity of _ckpt_process. The helper should handle the entire deletion loop while preserving the spinlock semantics (caller holds the lock).
Files to change
- src/block/block_ckpt.c — extract checkpoint deletion loop into helper function
Tasks
- [ ] Create __ckpt_delete_and_merge(session, block, ckptbase, ci) that encapsulates lines 729-825 (criterion: function handles the entire WT_CKPT_FOREACH deletion loop)
- [ ] Add spinlock assertion at the top of the function (criterion: WT_ASSERT_SPINLOCK_OWNED(session, &block->live_lock))
- [ ] Preserve all error handling and verbose logging (criterion: function returns error codes correctly)
- [ ] Refactor __ckpt_process to call the helper (criterion: deletion loop is replaced by a single function call)
- [ ] Measure complexity before and after: lizard src/block/block_ckpt.c 2>/dev/null || python3 -m lizard src/block/block_ckpt.c 2>/dev/null (criterion: CCN for __ckpt_process dropped by ≥10)
- [ ] Run existing block manager unit tests (criterion: ctest --test-dir build -R block passes)
Definition of Done
- [ ] New static function __ckpt_delete_and_merge handles the checkpoint deletion loop (lines 729-825)
- [ ] Function is called while block->live_lock is held (documented in function comment)
- [ ] Function handles: freeing root pages, freeing extent list blocks, merging alloc/discard lists, finding overlapping blocks, updating checkpoints, and clearing block modifications
- [ ] __ckpt_process calls this helper instead of inline logic
- [ ] Cyclomatic complexity of __ckpt_process is reduced by at least 10-12 points (measured with lizard src/block/block_ckpt.c 2>/dev/null || python3 -m lizard src/block/block_ckpt.c 2>/dev/null)
- [ ] All existing tests pass (run ctest --test-dir build -R block -j$(nproc))
- [ ] Code formatted with cd dist && ./s_clang_format