ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.1.0-rc0
    • Affects Version/s: None
    • Component/s: Transactions
    • None
    • Storage Engines, Storage Engines - Transactions
    • 3.532
    • SE Transactions - 2026-11-20
    • 2

      Problem

      When a session claims a prepared transaction recovered from a checkpoint (begin_transaction("claim_prepared_id=...")) and then commits or rolls it back with debug_mode=(table_logging=true), diagnostic builds fail an assertion in __txn_release (src/txn/txn.c:984–988):

      WiredTiger assertion failed: '... WT_SESSION_TXN_SHARED(session)->id == WT_TXN_NONE'
      

      Reproduced on develop at 4324a8b4c1.

      Cause

      1. A claimed prepared transaction has no transaction ID by design (__wt_txn_claim_prepared_txn, src/include/txn_inline.h:2066–2067).
      2. With table logging enabled, setting its commit or rollback timestamp writes a timestamp log record (__wt_txn_set_timestamp, src/txn/txn_timestamp.c:1423–1426).
      3. __txn_logrec_init needs a transaction ID for the record header and allocates one (src/txn/txn_log.c:222–228), publishing it in the session's slot of the global transaction table.
      4. At release, the transaction is prepared and has an ID, so __txn_release expects prepare to have already cleared the global slot. Here the ID was published after prepare, so the slot is still set.

      WT-5046 fixed the same assertion for empty prepared transactions by skipping timestamp logging when mod_count == 0 (src/txn/txn_log.c:404–410). Claimed prepared transactions, added later, aren't covered by that exception.

      In release builds the assertion is compiled out. From reading the code, the allocated ID stays published in that session's slot after release, which could hold back the oldest transaction ID until the session allocates another. This is not reproduced.

      Reproduction

      Based on test_prepare_discover02.py, reopening the backup with table logging:

      conn_config = 'precise_checkpoint=true,preserve_prepared=true'
      
      self.conn.set_timestamp('stable_timestamp=' + self.timestamp_str(50))
      self.conn.set_timestamp('oldest_timestamp=' + self.timestamp_str(50))
      self.session.create(uri, 'key_format=i,value_format=S')
      c = self.session.open_cursor(uri)
      self.session.begin_transaction()
      c[1] = 'prepared'
      self.session.prepare_transaction('prepare_timestamp=' + self.timestamp_str(100) +
          ',prepared_id=' + self.prepared_id_str(123))
      self.conn.set_timestamp('stable_timestamp=' + self.timestamp_str(150))
      session2 = self.conn.open_session()
      session2.checkpoint()
      self.backup('bkp', session2)
      
      conn2 = self.wiredtiger_open('bkp',
          conn_config + ',log=(enabled=true),debug_mode=(table_logging=true)')
      discover = conn2.open_session().open_cursor('prepared_discover:')
      discover.next()
      s = conn2.open_session()
      s.begin_transaction('claim_prepared_id=' + self.timestamp_str(discover.get_key()))
      # Either call aborts in __txn_release:
      s.commit_transaction('commit_timestamp=' + self.timestamp_str(200) +
          ',durable_timestamp=' + self.timestamp_str(210))
      # s.rollback_transaction('rollback_timestamp=' + self.timestamp_str(200))
      

      Passes with table_logging=false.

      In CI, test/checkpoint/recovery-test.sh verifies with -D, which enables table logging. The precise-checkpoint data-validation tasks reach this path whenever a recovery copy contains preserved prepared transactions.

      Proposed Solution

      Extend the WT-5046 exception: in __wti_txn_ts_log, also skip timestamp logging for a prepared transaction without a transaction ID. Alternatives (writing the record without an ID, or allocating an ID without publishing it) change how IDs are published and need review from the transaction owners.

      Impact

      Blocks WT-19044, whose test/checkpoint changes make recovery copies routinely contain preserved prepared transactions, so data-validation-stress-test-precise-checkpoint* would fail.

      Related: WT-5046. Blocks: WT-19044.

            Assignee:
            Dinujaya Rajakaruna
            Reporter:
            Dinujaya Rajakaruna
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: