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

Fix data race when updating btree's last record number

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT11.2.0, 7.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • 3
    • NachoCheese - 2023-10-03

      btree->last_recno gets updated in col_append_serial_func, where we're adding a new entry to the end of the btree and so might need to bump last_recno.

      /*
       * Set the calling cursor's record number. If we extended the file, update the last record
       * number.
       */
      *recnop = recno;
      if (recno > btree->last_recno)
          btree->last_recno = recno;
      

      The trouble here is that the btree could be accessed or updated by multiple threads (it's a property of the dhandle), so concurrent appends could leave it in a bad state. For example, two threads have a local recno greater than btree->recno, attempt to update it, and the smaller value wins. This would result in data corruption since we would reuse an old record number the next time we append.

            Assignee:
            ruby.chen@mongodb.com Ruby Chen
            Reporter:
            will.korteland@mongodb.com Will Korteland
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: