Select older non-aborted update instead of NULL when skipping committed preserved prepared update during reconciliation

XMLWordPrintableJSON

    • Storage Engines - Transactions
    • 210.154
    • SE Transactions - 2026-06-05
    • 3

      Background

      In src/reconcile/rec_visibility.c, when reconciliation runs on a WT_BTREE_GARBAGE_COLLECT tree and the selected update is a committed preserved prepared transaction (prepared_id != WT_PREPARED_ID_NONE), the code cannot write that update to the on-disk image — doing so would strip the prepared transaction identifier from the disk cell, breaking the association with the unresolved prepared cell on the stable btree.

      The current code handles this by nulling out upd_select->upd entirely:

      if (F_ISSET(btree, WT_BTREE_GARBAGE_COLLECT) && upd_select->upd != NULL &&
        upd_select->upd->prepared_id != WT_PREPARED_ID_NONE) {
          *has_newer_updatesp = true;
          upd_select->upd = NULL;
      }
      

      Improvement

      Instead of selecting NULL, reconciliation could walk back through the update chain from the selected update to find the most recent older update that:

      1. Is not aborted.
      2. Not from the same committed prepared transaction.

      If such an update exists and is otherwise eligible to be written (e.g., globally visible or satisfies the existing visibility rules), it should be selected as the on-disk value. This avoids writing nothing when a valid older stable value is available, reducing the number of updates that must stay in memory and improving garbage collection efficiency in the ingest path.

      Acceptance Criteria

      • When the selected update is a committed preserved prepared transaction on a WT_BTREE_GARBAGE_COLLECT tree, reconciliation falls back to the nearest non-aborted, non-prepared older update rather than unconditionally setting upd_select->upd to NULL.
      • If no such fallback update exists, behaviour is unchanged (NULL is selected, has_newer_updatesp is set).
      • Existing test coverage for the garbage-collect / ingest prepared-transaction path continues to pass.

            Assignee:
            Chenhao Qu
            Reporter:
            Chenhao Qu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: