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

Investigate reducing the number of read barriers in __wt_get_txn_snapshot

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      WT-4571 added 2 read barriers in transaction getting its snapshot (__wt_txn_get_snapshot) for safety reason. This ticket is to investigate the possibility of eliminating the read barriers.

       150 void
       151 __wt_txn_get_snapshot(WT_SESSION_IMPL *session)
       152 {
      ...
       217                 while (s != txn_state &&
       218                     (id = s->id) != WT_TXN_NONE &&
       219                     WT_TXNID_LE(prev_oldest_id, id) &&
       220                     WT_TXNID_LT(id, current_id)) {
       221                         /*
       222                          * If the transaction is still allocating its ID, then
       223                          * we spin here until it gets its valid ID.
       224                          */
       225                         WT_READ_BARRIER();
       226                         if (!s->is_allocating) {
       227                                 /*
       228                                  * There is still a chance that fetched ID is
       229                                  * not valid after ID allocation, so we check
       230                                  * again here. The read of transaction ID
       231                                  * should be carefully ordered: we want to
       232                                  * re-read ID from transaction state after this
       233                                  * transaction completes ID allocation.
       234                                  */
       235                                 WT_READ_BARRIER();
       236                                 if (id == s->id) {
       237                                         txn->snapshot[n++] = id;
       238                                         if (WT_TXNID_LT(id, pinned_id))
       239                                                 pinned_id = id;
       240                                         break;
       241                                 }
       242                         }
       243                         WT_PAUSE();
       244                 }
      

      The related discussion can be found on this github conversation: https://github.com/wiredtiger/wiredtiger/pull/4485#discussion_r261035635

      Note that this change can also be applied to __txn_oldest_scan which has also 2 read barriers. 

            Assignee:
            michael.cahill@mongodb.com Michael Cahill (Inactive)
            Reporter:
            hyeongwon.jang Hyeongwon Jang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: