Repository navigation
Fix race condition in file cache dynamic resize - #96980
Merged
Merged
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: 64962887/188743680, elements: 138/3000000 (s3_cache, protected)'. Root cause: in `FileCache::doDynamicResizeImpl`, `removeQueueEntries` created a temporary write lock that was released immediately after the call. Between that release and the subsequent `modifySizeLimits` call, concurrent `tryIncreasePriority` could promote entries from the probationary queue to the protected queue, increasing the protected queue size above the new limit. Fix: hold the write lock from `removeQueueEntries` through `modifySizeLimits`, preventing concurrent queue modifications (promotions, additions) between removal and limit application. This follows the locking order documented in Guards.h (`CachePriorityGuard` before `CacheStateGuard`). CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96930&sha=434475dfdaa26392f727dca644bb6cfb29aa4bb7&name_0=PR&name_1=Stress%20test%20%28amd_debug%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
This was referenced Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FileCache::doDynamicResizeImplwhere the write lock was released betweenremoveQueueEntriesandmodifySizeLimits, allowing concurrenttryIncreasePriorityto promote entries into the protected queueLOGICAL_ERRORexception: "Cannot modify size limits... not enough space freed" in the stress test (amd_debug)Guards.hCI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96930&sha=434475dfdaa26392f727dca644bb6cfb29aa4bb7&name_0=PR&name_1=Stress%20test%20%28amd_debug%29
#96930
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
LOGICAL_ERRORexception during config reload.🤖 Generated with Claude Code
Version info
26.2.1.776