Extract state validation and extent list setup 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

      The first ~75 lines of __ckpt_process handle checkpoint state validation, diagnostic verification, and extent list initialization/cleanup. This logic can be extracted into focused helper functions that reduce branching in the main flow. This ticket extracts: (1) checkpoint state validation logic (currently inline at lines 616-633), (2) extent list cleanup and initialization (lines 635-651), and (3) diagnostic verification (line 593).

      Files to change

      • src/block/block_ckpt.c — extract helper functions and refactor __ckpt_process

      Tasks

      • [ ] Create __ckpt_validate_state(session, block) that encapsulates lines 616-633 (criterion: function returns 0 on valid state or error code on invalid state)
      • [ ] Create __ckpt_init_extlists(session, ci) that encapsulates lines 635-651 (criterion: function initializes the three extent lists and returns 0 on success)
      • [ ] Refactor __ckpt_process to call these helpers (criterion: main function body is shorter and state validation is encapsulated)
      • [ ] 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 to verify no behavior change (criterion: ctest --test-dir build -R block passes)

      Definition of Done

      • [ ] New static function __ckpt_validate_state handles checkpoint state validation (WT_CKPT_INPROGRESS, WT_CKPT_PANIC_ON_FAILURE, etc.) and returns an error if state is invalid
      • [ ] New static function __ckpt_init_extlists handles cleanup and re-initialization of ci->ckpt_avail, ci->ckpt_alloc, and ci->ckpt_discard extent lists
      • [ ] __ckpt_process calls these helpers instead of inline logic
      • [ ] Cyclomatic complexity of __ckpt_process is reduced by at least 3-5 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: