There are situations, where one or more sessions may not run the dhandle sweep for a potentially long time. This can happen even though those sessions "play by the rules" in that they regularly call reset, regular open cursors, and close all their cursors. It happens because the dhandle sweep (__session_dhandle_sweep) is only called from __session_get_dhandle. Yes, that is called when a cursor is initially opened, but not when a cursor is reopened after being cached. So if a session is running and opening/closing cursors in its cache, until it gets a cursor cache "miss", or does something else schema related (e.g. drop/rename/create), it will not call dhandle sweep and potentially free dhandles that are stale.
We probably want to want to call the sweep on session reset. The sweep routine checks its time of last run to make sure it isn't (wastefully) run too often. We could also call it after a cached cursor is reopened (maybe every Nth time this happens).
As part of this work, we should fold in the work from WT-10211. That is, the session cursor cache has its own sweep, it should run potentially run more often and more aggressively if it has not been run in a while.