Fix possible deadlock in case of exception during disks initialization#94880
Merged
alexey-milovidov merged 2 commits intoClickHouse:masterfrom Jan 23, 2026
Merged
Conversation
Contributor
6ae9de3 to
adc6f60
Compare
Michicosun
approved these changes
Jan 23, 2026
| @@ -65,6 +65,7 @@ void DiskSelector::recordDisk(const std::string & disk_name, DiskPtr disk) | |||
|
|
|||
| void DiskSelector::initialize( | |||
Member
There was a problem hiding this comment.
The problem was that, in the case of an exception, merge_tree_disk_selector would not be set, and during shutdown, all created disks would not be shut down.
In case of `DiskSelector::initalize()` will throw, the `shutdown()` will not be called on each disk, and this will lead to possible deadlock [1] in case of `local_disk_check_period_ms > 0`. [1]: https://pastila.nl/?00620377/1d01d6bd2c9ab94267be3e03542b8496#EjAmYc7LfcQDTePv7Knncg==GCM This is possible in case of i.e. you create a cached disk over a regular one, regular is created, while cached is failed, with i.e.: Cannot wrap disk `s3_plain_rewritable` with cache layer `s3_plain_rewritable_cache`: there is no such disk (it should be initialized before cache disk).
adc6f60 to
c481162
Compare
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix possible deadlock in case of exception during disks initialization
In case of
DiskSelector::initalize()will throw, theshutdown()willnot be called on each disk, and this will lead to possible deadlock 1
in case of
local_disk_check_period_ms > 0.This is possible in case of i.e. you create a cached disk over a regular
one, regular is created, while cached is failed, with i.e.:
Note: marked as
Not for changelogsince the problem is possible only due to misconfiguration