wiredtiger/wiredtiger — pull request #778 by keithbostic (2013-11-30 22:55:58+00:00)
Title: Dhandle changes

@michaelcahill, @sueloverso:

Here's a possibility for #737.

I added an in-use counter and a time-of-death time stamp (time_t) to the WT_DATA_HANDLE structure.

When a WT_SESSION handle acquires a new reference to a data-source, it atomically updates the in-use counter. When a WT_SESSION handle releases the data-source, it decrements the in-use counter; if the counter goes to zero, the thread that did the decrement sets the time-of-death time stamp.

Whenever a WT_SESSION takes the schema lock in order to acquire a new reference, it reads the time, and if it's been at least 20 seconds since the last scan, the thread walks the list of WT_SESSION handles looking for handles where the in-use counter is 0 and the time-of-death timestamp is at least a minute in the past, and discards references to those handles.

I'm not in love with this change or anything, but it simplifies our sweeping code a bit, and it avoids sweeping more than a few times a minute, a change I'd like to have.

The cost is obvious -- two atomic updates, one on handle acquisition and one on handle close.

Anyway, I'm happy to just throw this away if nobody likes it.

The change mostly works (but don't pull it even if you like it, there's some path to acquiring a reference I didn't find, so it eventually asserts and drops core because the in-use counter goes negative).