Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-11558

Standardize the code to check the prepared state

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Transactions
    • 8
    • StorEng - Defined Pipeline

      In some places in the code, we have the following check of the prepared state:

            if (upd->prepare_state == WT_PREPARE_LOCKED || upd->prepare_state == WT_PREPARE_INPROGRESS)
      

      I think this is wrong and we may see the following race condition:

      1. Thread A reads the prepared state as in progress
      2. Thread B marks the prepared state as locked
      3. Thread A reads the prepared state again as locked and jumped out of the if section

      Instead we should check the state in the opposite direction as:

            if (upd->prepare_state == WT_PREPARE_INPROGRESS || upd->prepare_state == WT_PREPARE_LOCKED)
      

      or ensure we only read the prepared state once.

            Assignee:
            backlog-server-storage-engines [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            chenhao.qu@mongodb.com Chenhao Qu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: