Repository navigation
Conversation
`warnAboutDiskNotAllowedByRemoteHostFilter` added the disk to a static `std::set` and then read the whole set with `fmt::join`, with no lock. The comment said that disk creation holds `storage_policies_mutex`, but `Context::getOrCreateDisk` releases it before it runs the creator. So two custom disks with different names can be created at the same time, for example when tables are loaded at server start or by `UNDROP`. If both endpoints are not allowed by `remote_url_allow_hosts`, two threads change and read the set at the same time. This is a data race. Now a separate mutex guards the set, and the set is marked with `TSA_GUARDED_BY`. The lock is held until the warning is stored, so a message built from fewer disks cannot replace a newer one. Related: #2837 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8000
This branch has not been deployed
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.
warnAboutDiskNotAllowedByRemoteHostFilteradds a custom disk to a staticstd::setand then reads the whole set withfmt::jointo build thesystem.warningsmessage. It did this without a lock. The comment said that disk creation runs understorage_policies_mutex, butContext::getOrCreateDiskreleases this mutex before it runs the creator. So two custom disks with different names can be created at the same time.This happens at server start:
TablesLoaderloads tables in parallel, and each MergeTree table withSETTINGS disk = disk(...)creates its disk withattach = true(RemoteHostFilterCheck::Warn). If two such disks have endpoints that are not allowed byremote_url_allow_hosts, two threads change and read the set at the same time. This is undefined behavior and can crash the server while it loads tables.UNDROPuses the same path.Now a separate mutex guards the set, and the set is marked with
TSA_GUARDED_BY. The lock is held until the warning is stored, so a message built from fewer disks cannot replace a newer one.Testing: no new test. The race can be seen only under TSan with parallel creation of two custom disks with not allowed endpoints.
Related: #2837
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix a data race when the server loads in parallel several custom disks whose endpoints are not allowed by
remote_url_allow_hosts.Documentation entry for user-facing changes
...
CI/CD Options
Exclude tests:
Regression jobs to run:
🤖 Generated with Claude Code