Refactor checkpoint prepare-flag parsing to share code between prepare_discover and RTS

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Transactions
    • None
    • Storage Engines - Transactions
    • 409.19
    • SE Transactions - 2026-07-03
    • None

      Problem

      __prepared_discover_btree_has_prepare in src/prepared_discover/prepared_discover_walk.c (lines 11-37) duplicates checkpoint metadata config parsing that already exists in RTS. The function even has a comment calling this out:

      This configuration parsing is copied out of the rollback to stable implementation

      The duplicated logic iterates the checkpoint config sub-entries and checks the prepare flag:

      WT_RET(__wt_config_getones(session, config, "checkpoint", &cval));
      __wt_config_subinit(session, &ckptconf, &cval);
      for (; __wt_config_next(&ckptconf, &key, &cval) == 0;) {
          ret = __wt_config_subgets(session, &cval, "prepare", &value);
          if (ret == 0) {
              if (value.val)
                  *has_prepp = true;
          }
          WT_RET_NOTFOUND_OK(ret);
      }
      

      The same loop lives inside __wti_rts_btree_walk_btree_apply in src/rollback_to_stable/rts_btree_walk.c (lines 331-370), which extracts the same prepare flag along with newest_start_durable_ts, newest_stop_durable_ts, newest_txn, addr, and write_gen.

      Proposed Fix

      Extract a shared helper — e.g. _wt_meta_checkpoint_parse_info — in src/meta/meta_ckpt.c that iterates checkpoint config sub-entries and populates an output struct with all fields both callers need. Both prepared_discover_btree_has_prepare and _wti_rts_btree_walk_btree_apply replace their inline loops with a call to this helper.

      Files Affected

      • src/prepared_discover/prepared_discover_walk.c__prepared_discover_btree_has_prepare
      • src/rollback_to_stable/rts_btree_walk.c__wti_rts_btree_walk_btree_apply
      • src/meta/meta_ckpt.c — new shared helper (or a new meta_ckpt_utils.c)

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Chenhao Qu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: