-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: Cache and Eviction
-
None
-
Storage Engines - Transactions
-
86.712
-
SE Transactions - 2026-12-18
-
5
TLDR. A newly read page can be given a read_gen long into the future, then that page resists eviction until eviction server has caught up to that future. If these pages get dirtied with large updates, checkpoint will mark them clean, but leave the read_gen untouched. This effectively creates clean pages with large updates - that eviction won't remove for a long time.
The long version:
Background:
Each page carries a read_gen that helps decide the recency of page accesses. The eviction process uses this in the LRU scheme to decide what pages to queue for eviction and to prioritize. There is a global "clock" at conn->evict->read_gen, that ticks each time eviction server makes a pass to fill the queues. You can say that it is the "current" or "now" in the clock time, whereas page's read_gen derives from it as the "last accessed". Eviction server scans all pages to find the candidates for eviction based on the eviction mode combinations of clean, dirty and updates. The LRU process sorts based on the read_gen of the candidates and then selects an older fraction to evict. This LRU eviction process helps maintain an oldest seen read_gen at evict->read_gen_oldest.
Steps to see the bug:
1. Page's read_gen assignment and advancement is partially based on evict->read_gen_oldest:
First time a page is read, we call __wt_evict_touch_page() to set a read generation on the page. That function calls __wti_evict_read_gen_new() to set the read_gen to half way between what the eviction server has seen as the oldest and the current clock. This ensures that a one time table scan doesn't pollute the cache:
__wt_atomic_store_uint64_relaxed(
&page->read_gen, (__evict_read_gen(session) + S2C(session)->evict->read_gen_oldest) / 2);
If this is not the first time this page is read, there is already a read_gen, which is bumped to a bit more than the latest global clock, unless the page's read_gen is already in the future.
2. read_gen_oldest is derived from the eviction "score":
In __wti_evict_lru_walk(), each time the eviction server walks the pages to put in the queue, it updates the read_gen_oldest it has seen (ref):
read_gen_oldest = WT_READGEN_START_VALUE;
for (candidates = 0; candidates < entries; ++candidates) {
WT_READ_ONCE(read_gen_oldest, queue->evict_queue[candidates].score);
if (!__wti_evict_readgen_is_soon_or_wont_need(&read_gen_oldest))
break;
}
...
evict->read_gen_oldest = read_gen_oldest;
So read_gen_oldest is set to the head of the sorted queue based on the candidates's score, i.e. set to the smallest score in the queue.
3. Score is a read_gen unless doing dirty eviction:
Usually the score is a read_gen, slightly adjusted to prioritize some pages to evict, see __evict_entry_priority here.
But this is not true when there is dirty eviction set. To prioritize dirty pages over the clean pages, clean pages get a megabyte or less added to the score based on the clean page's size.
evict_entry->score = __evict_entry_priority(session, ref);
/* Adjust for size when doing dirty eviction. */
if (F_ISSET(S2C(session)->evict, WT_EVICT_CACHE_DIRTY) &&
evict_entry->score != WT_READGEN_EVICT_SOON && evict_entry->score != UINT64_MAX &&
!__wt_page_is_modified(ref->page))
evict_entry->score += WT_MEGABYTE -
WT_MIN(WT_MEGABYTE, __wt_atomic_load_size_relaxed(&ref->page->memory_footprint));
The score could also be a transaction-id, including 0 (in __evict_entry_priority()):
if (page->modify != NULL && F_ISSET(S2C(session)->evict, WT_EVICT_CACHE_DIRTY) &&
!F_ISSET(S2C(session)->evict, WT_EVICT_CACHE_CLEAN))
read_gen = __wt_atomic_load_uint64_relaxed(&page->modify->update_txn);
else
read_gen = __wt_atomic_load_uint64_relaxed(&page->read_gen);
Remember that read_gen_oldest eventually gets set to the lowest score among these candidates when these pages reach the head of the sorted queue. So it could be set to a million in the future to the page seen or to 0 (we care less about the 0 part here). For these pages to reach the head of the queue, you need certain conditions, but fairly common to get there in a large system:
- The dirty eviction needs to be active (often customers choose to set a low dirty target of 1%).
- We also need clean to be set to find clean pages of various sizes (at or around 80% cache consumption this is the most common case), and most pages will be clean and small in size to add the megabyte penalty to the score.
- Often enough we need that no dirty page is actually in the sort queue. This will be common for large caches, low dirty targets, during checkpoints with large files and small total collections, etc.
4. Incorrect initial page read's read_gen set from read_gen_oldest:
Now going back to initial assignment of (global read_gen + read_gen_oldest) / 2, could be now far in the future if the read_gen_oldest had extra size added, or could be in the past of the intended if oldest got set to 0. But for this issue we care more about the extra bit added.
When these conditions hit, we could be regularly reading in clean pages with read_gen in the future. These pages will not be selected for the eviction for a while now.
5. Dirtying and checkpoint cleaning adds to the size but doesnt reset the read_gen:
Imagine these new pages with read_gen in the future being read into the cache now in the above described conditions. The client now makes updates to these pages and they grow in size with large updates. The checkpoint will come and mark them clean, but leave the updates as such and also not touch the read_gen. This would lead to these clean pages with large updates in the cache that can not be evicted yet as their read_gen is far in the future.
I think WT-15538 has multiple "causes". In some cases, this could be one of them or worsen update eviction in general.
- is related to
-
SERVER-18829 Cache usage exceeds configured maximum during index builds under WiredTiger
-
- Closed
-
-
WT-2391 De-prioritize eviction from indexes
-
- Closed
-
-
WT-15538 Investigate slow eviction behavior when updates ratio is high
-
- Open
-
-
WT-2729 Focus eviction walks in largest trees
-
- Closed
-
-
WT-2816 Improve WiredTiger eviction performance
-
- Closed
-
-
WT-2902 Enhance eviction to work better with update heavy YCSB load
-
- Closed
-
- related to
-
WT-15538 Investigate slow eviction behavior when updates ratio is high
-
- Open
-