wiredtiger/wiredtiger — pull request #700 by keithbostic (2013-10-03 12:45:04+00:00)
Title: support eviction of clean internal pages that have children

@michaelcahill, you suggested it might be possible to attempt to evict a clean internal page with children.

Looking at this again, I don't think it's possible. There's code in __rec_review():

```
/*
* Fail if any page in the top-level page's subtree won't be merged into
* its parent, the page that cannot be merged must be evicted first.
* The test is necessary but should not fire much: the eviction code is
* biased for leaf pages, an internal page shouldn't be selected for
* eviction until its children have been evicted.
*/
mod = page->modify;
if (!top && (mod == NULL || !F_ISSET(mod,
WT_PM_REC_EMPTY | WT_PM_REC_SPLIT | WT_PM_REC_SPLIT_MERGE)))
return (EBUSY);
```

which willl fail if we ever get here with a clean internal page with children.

In other words, __wt_rec_evict() must discard a full tree in the case of a dirty page because there might be split, empty or split-merge pages below it that are being discarded as well; __wt_rec_evict() only has to discard the single page in the case of a clean page, there can't be anything below it.

There is some cost in making this change: we would have to walk clean internal pages when they're evicted, looking for children, which we don't have to do now. That said, internal pages are supposed to be small, it's not that big a cost.

So:

1. We could relax this code so clean internal pages with children can be evicted, but I don't see much value in doing that work. I think the LRU bias for leaf pages, coupled with the fact that the parent is going to be visited every time the leaf page is visited, will pretty much guarantee it never happens.
2. We could pull this branch, just to make sure we don't introduce a bug in the future.
3. We could add a DIAGNOSTIC check of clean internal pages so we catch any bugs we introduce in the future.
4. We could just discard this branch.

I don't like the first option much, but the others are all fine with me. Your choice?