[Reverted] Fix segfault in clearCaches when table is dropped during query#95074
Merged
alexey-milovidov merged 4 commits intomasterfrom Jan 25, 2026
Merged
[Reverted] Fix segfault in clearCaches when table is dropped during query#95074alexey-milovidov merged 4 commits intomasterfrom
clearCaches when table is dropped during query#95074alexey-milovidov merged 4 commits intomasterfrom
Conversation
When a table is dropped while a query is running and holding references to its parts (via `RangesInDataPart`), the part's destructor would crash when calling `clearCaches()`. This happened because `clearCaches()` accessed `storage.getPrimaryIndexCache()` which dereferences settings from the already-destroyed storage object. The fix stores a `ContextWeakPtr` in `IMergeTreeDataPart` and uses it in `clearCaches()` to access caches directly from the context, bypassing the potentially-destroyed storage. If the context is no longer available, the method returns early (cache cleanup is not critical and caches have their own eviction). Co-Authored-By: Claude Opus 4.5 <[email protected]>
Contributor
|
Workflow [PR], commit [2d5df63] Summary: ❌
|
The test now properly filters out `UNKNOWN_TABLE` errors (code 60) which are expected when the table is dropped during query execution. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The `filter_expected_errors` function was not properly filtering all expected errors during the race condition: 1. "UNKNOWN_TABLE" didn't match the actual error message "Unknown table expression identifier" - changed to "Unknown table" 2. Code 279 errors (`ALL_CONNECTION_TRIES_FAILED`) were not filtered at all - added filters for "All connection tries failed" and "connect to any replica" Co-Authored-By: Claude Opus 4.5 <[email protected]>
Member
Author
|
Reverting, because two failures found by CI after merge: |
clearCaches when table is dropped during queryclearCaches when table is dropped during query
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.
When a table is dropped while a query is running and holding references to its parts (via
RangesInDataPart), the part's destructor would crash when callingclearCaches(). This happened becauseclearCaches()accessedstorage.getPrimaryIndexCache()which dereferences settings from the already-destroyed storage object.The fix stores a
ContextWeakPtrinIMergeTreeDataPartand uses it inclearCaches()to access caches directly from the context, bypassing the potentially-destroyed storage. If the context is no longer available, the method returns early (cache cleanup is not critical and caches have their own eviction).Changelog category (leave one):
See https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=37f13730553a28b303b22da3a29a4367e8a7aa4c&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29