Repository navigation
Fix SLRU and SplitFileCachePriority dynamic resize bugs - #102396
Conversation
|
Still working on integration tests |
|
Workflow [PR], commit [ebbb5bb] Summary: ❌
AI ReviewSummaryThis PR fixes two real dynamic-resize correctness issues in filesystem cache: SLRU cross-queue eviction accounting during total cleanup, and failed-eviction restoration routing back to the original SLRU sub-queue. It also fixes a no-op guard bug in ClickHouse Rules
Final Verdict
|
8064bfc to
77d9742
Compare
…ecovery path Fix `LOGICAL_ERROR` abort during SLRU filesystem cache dynamic resize (issue #95983, STID `4012-44fe`). **Per-queue stat fix (core bug):** `SLRUFileCachePriority::collectCandidatesForEviction` shared a single `FileCacheReserveStat` across both sub-queue passes. The probationary pass accumulated `releasable_size`, then the protected pass's stopping condition was immediately satisfied by probationary leftovers — so zero protected candidates were collected. `modifySizeLimits` then threw because the protected queue still exceeded its new limit. Fix: use per-queue local stat objects and merge them afterward. **SLRU recovery path fix:** When eviction fails and entries are restored, they now go back to their original queue (protected or probationary) instead of all defaulting to probationary. `EvictionCandidates` captures the queue type before invalidation, and a new `addForRestore` virtual method routes entries back to the correct sub-queue. Recovery uses `result_limits = prev_limits` since entries existed under those limits. **`SplitFileCachePriority::modifySizeLimits` no-op guard fix:** The no-op guard compared `system_segment_size_ratio` (Data/System split) against `size_ratio_` (SLRU protected/probationary ratio) — different concepts. This caused real resizes to be silently skipped. Fix: compare only `max_size` and `max_elements`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101427&sha=7b67d034be1a37512c7fbc8c9b428f2eeb0907ba&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29 Related PR: #101427 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
77d9742 to
992169f
Compare
| # Since 100 is also the starting value, we double-check after a delay | ||
| # to confirm the thread actually ran. | ||
| for _ in range(30): | ||
| if get_max_size() == 100: |
There was a problem hiding this comment.
The loop can exit without proving the failpoint path was exercised.
max_size is already 100 before SYSTEM RELOAD CONFIG, so if get_max_size() == 100 is true immediately, and after the extra sleep(1) the second check can still be 100 even when resize never attempted. In that case this test may pass while not validating the failed-eviction recovery path.
Please gate loop exit on evidence that resize was attempted (for example, a log/metric signal from failed dynamic resize), rather than on max_size == 100 alone.
|
|
||
| # Poll for the real resize to complete | ||
| for _ in range(30): | ||
| if get_max_size() == 10: |
There was a problem hiding this comment.
10 path completed. If get_max_size() never reaches 10 within 30 seconds, the test still continues to assert get_downloaded_size() <= 10, which may already be true from the pre-resize state (e.g., when cached data is small).
Please assert the target is reached after the polling loop, e.g. assert get_max_size() == 10, so the test fails when dynamic resize does not happen.
Replace fragile timing-based polling with log-message-based detection for the resize failure path, and add explicit `max_size` assertion after successful resize. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
When `use_split_cache` + SLRU are composed, `SplitIterator::getType` returns `SplitCache_Data`/`SplitCache_System` instead of the inner `SLRU_Protected`/`SLRU_Probationary` type. This caused `addForRestore` to route all restored entries to probationary after failed eviction, reintroducing the queue-corruption bug. Override `getNestedOrThis` in `SplitIterator` to delegate to the inner iterator, and use `getNestedOrThis()->getType()` when saving the original queue type in `EvictionCandidates::removeQueueEntries`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… test Replace the hand-rolled sleep+`contains_in_log` loop with the `count_log_lines`/`wait_for_log_line` pattern, which correctly scopes the log search to lines written after the test action and avoids matching stale log entries from earlier test cases. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: 85.83% (103/120) · Uncovered code |
Add a third cache base path to the test fixture setup/teardown for testing SLRU resize statistics. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Cherry pick #102396 to 26.3: Fix SLRU and SplitFileCachePriority dynamic resize bugs
Backport #102396 to 26.3: Fix SLRU and SplitFileCachePriority dynamic resize bugs
Fix
LOGICAL_ERRORabort during SLRU filesystem cache dynamic resize (issue #95983, STID4012-44fe).Per-queue stat fix (core bug):
SLRUFileCachePriority::collectCandidatesForEvictionshared a singleFileCacheReserveStatacross both sub-queue passes. The probationary pass accumulatedreleasable_size, then the protected pass's stopping condition was immediately satisfied by probationary leftovers — so zero protected candidates were collected.modifySizeLimitsthen threw because the protected queue still exceeded its new limit. Fix: use per-queue local stat objects and merge them afterward.SLRU recovery path fix:
When eviction fails and entries are restored, they now go back to their original queue (protected or probationary) instead of all defaulting to probationary.
EvictionCandidatescaptures the queue type before invalidation, and a newaddForRestorevirtual method routes entries back to the correct sub-queue. Recovery usesresult_limits = prev_limitssince entries existed under those limits.SplitFileCachePriority::modifySizeLimitsno-op guard fix:The no-op guard compared
system_segment_size_ratio(Data/System split) againstsize_ratio_(SLRU protected/probationary ratio) — different concepts. This caused real resizes to be silently skipped. Fix: compare onlymax_sizeandmax_elements.CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101427&sha=7b67d034be1a37512c7fbc8c9b428f2eeb0907ba&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
Closes #95983
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
LOGICAL_ERRORabort during SLRU filesystem cache dynamic resize caused by shared eviction statistics across sub-queues and incorrect recovery path for failed candidates.Documentation entry for user-facing changes
Version info
26.4.1.90626.3.14.49