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.