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

Fix unsafe setting of dhandle flags

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • WT11.2.0, 7.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      As part of WT-11055, it's noted that in wt_conn_dhandle_close, outside of the spinlock, we have this code:

       F_SET(dhandle, WT_DHANDLE_EVICTED);

      That's basically:

      t = dhandle->flags;
      t |= WT_DHANDLE_EVICTED;
      dhandle->flags = t; 

      That can race with any other code setting one or more dhandle flags, so that one of the threads doesn't get their flag set. Most callers to wt_conn_dhandle_close have the handle locked exclusively, but the sweep_discard does not. So sweep_discard could be messing with flags, while some other thread is also setting dhandle flags in this or some other function that is expected to be called with exclusive access. I think that opens a number of holes.

      One solution is to all the accesses to dhandle flags to use the atomic flags macros.

      Another possibility, if we're worried about any performance impact of that change is to note that everything would work if the evicted flag wasn't part of the regular dhandle flag set. It could be in its own flag set or as a separate boolean.

            Assignee:
            donald.anderson@mongodb.com Donald Anderson
            Reporter:
            donald.anderson@mongodb.com Donald Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: