Repository navigation
Fix SLRU file cache exception during dynamic resize - #96142
Conversation
The stress test (amd_debug) was failing with: Logical error: 'Cannot modify size limits to 62914560 in size and 3000000 in elements: not enough space freed. Current size: 64273255/188743680, elements: 87/3000000 (s3_cache, protected)'. The exception was thrown from `LRUFileCachePriority::modifySizeLimits` when it found the protected sub-queue's current size (64.3 MB) exceeded its new limit (62.9 MB). Root cause: `FileCache::doDynamicResizeImpl` computed eviction needs based on total cache size vs. desired total limit. When the total cache size was under the new total limit, it concluded no eviction was needed and directly called `modifySizeLimits`. However, for SLRU the total limit is split between the protected and probationary sub-queues using a ratio. Even when the total fits, the protected sub-queue can exceed its new sub-limit if the data distribution is skewed. The same issue could also affect `SplitFileCachePriority` which distributes limits between Data and System segments. Fix: add a virtual method `collectEvictionInfoForResize` to `IFileCachePriority` that takes the desired limits (rather than total eviction amounts) and computes per-sub-queue eviction correctly: - The default implementation (used by LRU) computes total eviction from total size vs. desired limit, same as before. - `SLRUFileCachePriority` overrides it to compare each sub-queue's current size against its new sub-limit derived from the desired total and the SLRU ratio, ensuring eviction from the protected queue even when the total fits. - `SplitFileCachePriority` overrides it to distribute desired limits between its Data and System segments and delegates to each inner priority's `collectEvictionInfoForResize`. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Workflow [PR], commit [e5d9bbe] Summary: ❌
|
There was a problem hiding this comment.
This bug was introduced in #82764, which was merged in 26.1, which is also visible by CI db. So let's backport this fix to 26.1, because our chineese friends are using this feature.
Please also be aware that Sync PR will also need modifications as there is one more derived class of IFileCachePriority there.
| elements_to_evict, | ||
| /* reservee */nullptr, | ||
| /* is_total_space_cleanup */false, | ||
| /* is_dynamic_resize */true, |
There was a problem hiding this comment.
Please remove is_dynamic_resize flag from collectEvictionInfo and the code which was under this flag to avoid ambiguity because now there is collectEvictionInfo(..., is_dynamic_resize) and collectEvictionInfoForResize, so let's have only one way to do the resize... This should also simplify SLRUFileCachePriority::collectEvictionInfoForResize a little bit as it uses the first one instead of a second.
| magic_enum::enum_name(getType())); | ||
| } | ||
|
|
||
| EvictionInfoPtr IFileCachePriority::collectEvictionInfoForResize( |
There was a problem hiding this comment.
Let's make derived classes always define the implementation instead of having a default implementation in the base class
…nInfoForResize` pure virtual Remove the `is_dynamic_resize` parameter from `collectEvictionInfo` and all code that was gated behind it. Now resize eviction is handled exclusively by `collectEvictionInfoForResize`, removing the ambiguity of having two code paths for the same operation. Make `collectEvictionInfoForResize` pure virtual in `IFileCachePriority` instead of providing a default implementation in the base class. Move the default implementation into `LRUFileCachePriority`. Simplify `SLRUFileCachePriority::collectEvictionInfoForResize` to delegate to each sub-queue's `collectEvictionInfoForResize` directly. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The stress test (amd_debug) was failing with:
Logical error: 'Cannot modify size limits to 62914560 in size and
3000000 in elements: not enough space freed. Current size:
64273255/188743680, elements: 87/3000000 (s3_cache, protected)'.
Here: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=3561bc3928658933a66f6f1c6f28fa517f4eb841&name_0=MasterCI&name_1=Stress%20test%20%28amd_debug%29&name_1=Stress%20test%20%28amd_debug%29
The exception was thrown from
LRUFileCachePriority::modifySizeLimitswhen it found the protected sub-queue's current size (64.3 MB) exceeded its new limit (62.9 MB).Root cause:
FileCache::doDynamicResizeImplcomputed eviction needs based on total cache size vs. desired total limit. When the total cache size was under the new total limit, it concluded no eviction was needed and directly calledmodifySizeLimits. However, for SLRU the total limit is split between the protected and probationary sub-queues using a ratio. Even when the total fits, the protected sub-queue can exceed its new sub-limit if the data distribution is skewed. The same issue could also affectSplitFileCachePrioritywhich distributes limits between Data and System segments.Fix: add a virtual method
collectEvictionInfoForResizetoIFileCachePrioritythat takes the desired limits (rather than total eviction amounts) and computes per-sub-queue eviction correctly:SLRUFileCachePriorityoverrides it to compare each sub-queue's current size against its new sub-limit derived from the desired total and the SLRU ratio, ensuring eviction from the protected queue even when the total fits.SplitFileCachePriorityoverrides it to distribute desired limits between its Data and System segments and delegates to each inner priority'scollectEvictionInfoForResize.Changelog category (leave one):
Version info
26.2.1.368