8000 Guard the list of custom disks not allowed by remote_url_allow_hosts by k-morozov · Pull Request #2939 · Altinity/ClickHouse · GitHub
[go: up one dir, main page]

Skip to content

Guard the list of custom disks not allowed by remote_url_allow_hosts - #2939

Open
k-morozov wants to merge 1 commit into
antalya-26.8from
bugfix/antalya-26.8/custom-disk-warning-race
Open

k-morozov wants to merge 1 commit into
antalya-26.8from
bugfix/antalya-26.8/custom-disk-warning-race

Conversation

@k-morozov
@k-morozov k-morozov commented Nov 21, 2026 •
Copy link
Copy Markdown
Collaborator

warnAboutDiskNotAllowedByRemoteHostFilter adds a custom disk to a static std::set and then reads the whole set with fmt::join to build the system.warnings message. It did this without a lock. The comment said that disk creation runs under storage_policies_mutex, but Context::getOrCreateDisk releases 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: TablesLoader loads tables in parallel, and each MergeTree table with SETTINGS disk = disk(...) creates its disk with attach = true (RemoteHostFilterCheck::Warn). If two such disks have endpoints that are not allowed by remote_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. UNDROP uses 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):

  • Bug Fix (user-visible misbehavior in an official stable release)

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:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (m 8000 ostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

🤖 Generated with Claude Code

`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>
@github-actions
Copy link
Copy Markdown

Workflow [PR], commit [2dff184]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CAS rejoin misses the access-check object, and parallel custom-disk warnings race

1 participant

0