Extract live checkpoint update logic from __ckpt_process

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Checkpoints
    • None

      Lines 832-866 of _ckpt_process handle updating the final "live" checkpoint based on the current system state. This includes truncating the file, calculating checkpoint sizes, and calling _ckpt_update. This logic can be extracted into a helper function. The helper should be called while holding block->live_lock, and should encapsulate the logic at the live_update label through the end of the live checkpoint handling.

      Files to change

      • src/block/block_ckpt.c — extract live checkpoint update logic

      Tasks

      • [ ] Create __ckpt_update_live(session, block, ckptbase, ci, ckpt_size) that encapsulates lines 832-866 (criterion: function handles live checkpoint updates)
      • [ ] Add spinlock assertion at the top of the function (criterion: WT_ASSERT_SPINLOCK_OWNED(session, &block->live_lock))
      • [ ] Handle checkpoint size calculation and bounds checking (criterion: function correctly sets ckpt->size and ci->ckpt_size)
      • [ ] Refactor __ckpt_process to call the helper (criterion: live_update section 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 ≥3)
      • [ ] Run existing block manager unit tests (criterion: ctest --test-dir build -R block passes)

      Definition of Done

      • [ ] New static function __ckpt_update_live handles live checkpoint update logic (lines 832-866)
      • [ ] Function is called while block->live_lock is held (documented in function comment)
      • [ ] Function handles: file truncation, checkpoint size calculation, and calling __ckpt_update for the ADD checkpoint
      • [ ] __ckpt_process calls this helper instead of inline logic
      • [ ] Cyclomatic complexity of __ckpt_process is reduced by at least 3-4 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

            Assignee:
            Etienne Petrel
            Reporter:
            Etienne Petrel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: