Lack of ordering constraints around WT_PREPARE_LOCKED

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Transactions
    • None
    • Storage Engines - Transactions
    • 159.467
    • SE Transactions - 2026-05-08
    • 1

      When we call `__txn_apply_prepare_state_update` we first assign `WT_PREPARE_LOCKED` to `prepare_state` to "lock" it from readers and we via an atomic write with release ordering.

      However, that’s not sufficient, since release ordering only prevents instructions earlier in the execution flow from being reordered past the release-store instruction. It does not prevent operations located after the release-store from being reordered before it.

      So actually the following code:

      __wt_atomic_store_uint8_v_release(&upd->prepare_state, WT_PREPARE_LOCKED);
       
      __wt_atomic_store_uint64_relaxed(&upd->upd_start_ts, time_point->commit_timestamp);
      __wt_atomic_store_uint64_relaxed(&upd->upd_durable_ts, time_point->durable_timestamp);

      Can be reordered to: 

      __wt_atomic_store_uint64_relaxed(&upd->upd_start_ts, time_point->commit_timestamp);
      __wt_atomic_store_uint64_relaxed(&upd->upd_durable_ts, time_point->durable_timestamp); 
      
      __wt_atomic_store_uint8_v_release(&upd->prepare_state, WT_PREPARE_LOCKED); 

       

            Assignee:
            Chenhao Qu
            Reporter:
            Ivan Kochin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: