Replace WT_ACQUIRE_BARRIER with explicit atomic loads in WT_TIME_WINDOW_SET_START/STOP macros

XMLWordPrintableJSON

    • Storage Engines, Storage Engines - Transactions
    • 0.038
    • SE Transactions - 2026-05-08
    • 1

      The WT_TIME_WINDOW_SET_START and WT_TIME_WINDOW_SET_STOP macros in src/include/timestamp_inline.h previously read txnid unconditionally before the write_prepare branch, then applied a WT_ACQUIRE_BARRIER() only in the aborted-transaction fallback path.

      This change:

      1. Moves the txnid read inside the write_prepare branch so the correct memory ordering is applied per code path.
      2. In the prepare path, replaces the direct read + WT_ACQUIRE_BARRIER() with __wt_atomic_load_uint64_v_acquire, making acquire semantics explicit.
      3. In the non-prepare path, uses __wt_atomic_load_uint64_v_relaxed since acquire ordering is not required there.
      4. For the aborted-transaction fallback (upd_saved_txnid), uses __wt_atomic_load_uint64_relaxed instead of a plain read after a barrier.

      This eliminates the ad-hoc barrier, makes the intended memory ordering self-documenting, and ensures only the paths that need acquire semantics pay for them.

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

              Created:
              Updated:
              Resolved: