TSan data race on txn_global.last_ckpt_timestamp between checkpoint and sweep server

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Checkpoints, Sweep Server
    • None
    • Storage Engines - Transactions
    • 127.959
    • None
    • None
    • Not Needed

      WT-17323 (commit 8334eb7f66) added an atomic read of txn_global.last_ckpt_timestamp in the sweep server (__sweep_close_dhandle_locked, src/conn/conn_sweep.c:172), but all writers still use plain stores (src/checkpoint/checkpoint_txn.c:1887, src/conn/conn_layered_checkpoint_pick_up.c:850). TSan reports the mixed access as a data race.

      Fails intermittently in format-stress-test-disagg-switch-tsan (switch mode creates ingest tables for the sweep server to expire). The format run itself succeeds; the process aborts on the TSan report (abort_on_error=1). Reproduced on two unrelated PR patches:

      TSan report (abridged)
      WARNING: ThreadSanitizer: data race (pid=16518)
        Write of size 8 at 0xffff8e001120 by thread T107 (mutexes: write M0, write M1):
          #0 __checkpoint_db_internal src/checkpoint/checkpoint_txn.c:1887:46
          #1 __checkpoint_db_wrapper src/checkpoint/checkpoint_txn.c:2006:11
          #2 __wt_checkpoint_db src/checkpoint/checkpoint_txn.c:2085:9
        Previous atomic read of size 8 at 0xffff8e001120 by thread T27:
          #0 __wt_atomic_load_uint64_relaxed src/include/gcc.h:409:1
          #1 __sweep_close_dhandle_locked src/conn/conn_sweep.c:172:13
          #2 __sweep_expire_one src/conn/conn_sweep.c:205:5
          #3 __sweep_server src/conn/conn_sweep.c:540:13
      SUMMARY: ThreadSanitizer: data race src/checkpoint/checkpoint_txn.c:1887:46 in __checkpoint_db_internal
      

      Suggested fix: convert all accesses to last_ckpt_timestamp (declared wt_shared in src/include/txn.h) to atomic loads/stores; same for the adjacent last_ckpt_disaggregated_schema_epoch write.

      Related: WT-17323, WT-17263 (PR #14123), WT-17959 (PR #14124).

            Assignee:
            Shoufu Du
            Reporter:
            Yury Ershov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: