Skip to content

Remove use_compact_format_in_distributed_parts_names, always use compact format - #120186

Merged
alexey-milovidov merged 18 commits into
masterfrom
remove-non-compact-distributed-parts-names
Oct 1, 2026
Merged

alexey-milovidov merged 18 commits into
masterfrom
remove-non-compact-distributed-parts-names

Conversation

@tavplubix

@tavplubix tavplubix commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

…compact format

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The setting use_compact_format_in_distributed_parts_names is obsolete now. The non-compact directory format for the async INSERT queue of a Distributed table has been removed. The setting was 1 by default since version 21.1. Switch to 1 and let the queue drain before upgrading.


Workflow [PR]
Sync PR [sync-upstream/pr/120186]

Version info

  • Merged into: 26.10.1.1126-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [19231f1]

Summary: ✅


AI Review

Summary

This PR removes the legacy async INSERT queue directory format for Distributed tables, always writes compact queue names, and quarantines leftover or malformed queue directories instead of replaying them. I reviewed the current diff and all prior discussion threads against the current code and did not find any remaining correctness, safety, or compatibility issues that warrant a new review comment on the current head.

Final Verdict

✅ No new findings on the current head.

LLVM Coverage Report

Measured on commit 19231f1.

Metric Baseline Current Δ
Lines 87.90% 87.90% +0.00%
Functions 91.80% 91.70% -0.10%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 155/161 (96.27%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes comp-distributed Distributed table engine & query routing across shards (sharding/load balancing). labels Sep 15, 2026
Comment thread src/Storages/StorageDistributed.cpp Resolved
@tavplubix
tavplubix force-pushed the remove-non-compact-distributed-parts-names branch from 42ffee7 to c93a46f Compare September 17, 2026 16:52
Comment thread src/Storages/StorageDistributed.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 19231f1bb with master a4087fc3f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

26 object files changed (-13.48 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/StorageDistributed.cpp.o 1.04 MiB 1.07 MiB +28.48 KiB (+2.67%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

113 translation units recompiled, 1168 s compile time in total, 113 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this change! LGTM.

@alexey-milovidov alexey-milovidov self-assigned this Sep 21, 2026
alexey-milovidov and others added 3 commits September 21, 2026 09:42
…distributed-parts-names

# Conflicts:
#	src/Core/SettingsChangesHistory.cpp
A subdirectory of the async `INSERT` spool whose name is not one
`DistributedSink` writes is renamed to `unrecognized_<hash>` on start and
gets no `DistributedAsyncInsertDirectoryQueue`, so it is absent from
`cluster_nodes_data` and from everything derived from it, including the
cleanup done by `TRUNCATE TABLE`. Its files still occupy disk, and there
was no way to drop them from SQL.

`TRUNCATE TABLE` now sweeps the `unrecognized_*` subdirectories of every
disk of the table as well, and the integration test asserts that the spool
directory is empty afterwards.

The bytes of such a directory are deliberately still left out of
`totalBytes`, `system.distribution_queue` and the `bytes_to_delay_insert` /
`bytes_to_throw_insert` limits: those files can never be sent, so counting
them as backlog would delay or reject inserts forever instead of clearing
on its own.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The `Upgrade check` flags every `<Error>` line the server writes, and an
upgrade from a version that still wrote the old directory names produces
one for every `Distributed` table with a non-empty queue. That is the
expected handling of the leftover queue, not a failure of the server, so
log it at the warning level, like the message the following starts write
for the same directory.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failures below and provide a fix in a separate PR; if a fix is already in progress, link it here.

  • Upgrade check (amd_release): report — the Error message in clickhouse-server.log check is failing fleet-wide (119 FAIL rows in the last 10 days across many unrelated PRs) on Code: 344. DB::Exception: Transactions require Keeper to advertise \LIST_WITH_STAT_AND_DATA`, `FILTERED_LIST`, `MULTI_READ` and `CHECK_STAT` feature flags. Upgrade the Keeper cluster. (SUPPORT_IS_DISABLED)fromBackgroundJobsAssignee::threadFunc/AsyncLoader::worker. I could not find an open issue for it. The one message in that report that was this PR's own (the rename of a legacy async-INSERT` directory) is fixed here in 1ea1250 by logging it as a warning instead of an error.
  • Performance Comparison (arm_release, master_head, 5/6): report — the 10 run errors are all iceberg_suite_tpch query failures, and no query of any shard is slower (0 slower, 6 faster, 7 unstable over 3461 queries). Nothing in this PR touches Iceberg.
  • Build profile diff: known infrastructure failure, RuntimeError: CI logs cluster query failed (Build profile diff fails fleet-wide with No connection to LogCluster #120462).

Comment thread src/Storages/StorageDistributed.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

All three already have an owner, so there is no separate PR from me: two of the fixes are merged and the third is yours.

Upgrade check / Error message in clickhouse-server.log, Code: 344 ... SUPPORT_IS_DISABLED. There was no open issue, which is why the search came up empty; I fixed it directly in #120932, merged 2026-09-21 01:07 UTC as e0b84a678031 (26.10.1.319). configure() in tests/docker_scripts/stress_tests.lib randomized list_with_stat_and_data and check_stat off, and with those two disabled any transactional part already in the data directory fails to load with exactly that message, from part loading and from the background assignee. The PR stops randomizing those two flags and keeps the other three, matching how the integration transaction tests pin them.

On that check the message ran from 2026-09-18 12:03 to 2026-09-21 05:35 UTC, 61 rows over PR runs, never on master. 05:35 UTC is the last occurrence anywhere: in the 63 Upgrade check runs started since, zero, against 18 rows in 342 runs in the 24 hours before the merge. The few rows between the merge and 05:35 are pipelines whose tested tree predates it, so this PR goes green here once its CI builds a tree containing e0b84a678031.

Performance Comparison, iceberg_suite_tpch run errors. There is an issue: #120921, TPC-H Q5 over the CI tpch_ice10 dataset timing out at the runner's 15 s max_execution_time after having run in ~350 ms. Caused by #120176, fixed by the revert #120923, merged 2026-09-19 18:34 UTC, after the sha tested here. Share of arm_release, 5/6 runs that produce no iceberg_suite_tpch rows at all: 4.8% on 09-18 and 5.9% on 09-19, then 0.8% on 09-20 and 2.4% today, back to the pre-regression background.

Build profile diff. Agreed on #120462, and the fix in flight is #121048. Nothing further owed from me on that one.

alexey-milovidov and others added 2 commits September 22, 2026 00:44
…distributed-parts-names

# Conflicts:
#	src/Core/SettingsChangesHistory.cpp
…_replicas` name as a directory queue

`DistributedSink::writeToShard` creates one directory per destination, so no writer
produces a comma-joined name any more. `isDirectoryQueueName` still split the name on
commas and accepted `shard1_replica1,shard1_replica2` as live, letting a stray
subdirectory bypass the `unrecognized_*` quarantine and `parseAddresses` replay its
files to both replicas on attach. Both now take the whole name as a single destination.
The integration test gets the comma-joined case.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, @groeneai. Merged master into the branch, which brings in e0b84a678031 (#120932) for the Upgrade check message and the revert #120923 for the iceberg_suite_tpch run errors, so both reds should clear on the next CI run. Build profile diff stays with #120462 / #121048.

Comment thread src/Interpreters/Cluster.cpp Resolved
alexey-milovidov and others added 2 commits September 22, 2026 18:53
…ue name

`Cluster::Address::tryParseFullString` used `tryParse<UInt32>` for the shard and replica indices,
which also accepts spellings the writer never produces: a leading zero (`shard01_replica1`,
`shard1_replica01`, `shard01_all_replicas`) or an explicit sign (`shard+1_replica1`). Since
`StorageDistributed::isDirectoryQueueName` takes any successful parse as a live queue, such a
directory would escape the `unrecognized_*` quarantine and its `.bin` files would be replayed on
attach, breaking the invariant that only writer-produced directory names stay active.

Reconstruct the canonical name from the parsed indices and accept the string only if it
round-trips exactly. The four alternate spellings are added to `test_invalid_shard_directory_format`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Pushed 5315499: the AI-review Major on Cluster::Address::tryParseFullString is adopted (only the canonical shardN_replicaM / shardN_all_replicas spelling is a directory queue name now, with the four alternate spellings covered by test_invalid_shard_directory_format), and master is merged again. The only red on the previous run, 05210_skip_index_type_from_alter_session_setting in Stateless tests (arm_asan_ubsan, targeted), is the fleet-wide merge_max_block_size randomization failure fixed by #121126, which was not in the branch yet; the merge pulls it in.

Comment thread src/Storages/StorageDistributed.cpp Resolved
Address review: renaming an unrecognized spool subdirectory to `unrecognized_<hash>`
discarded its old name, which for a directory written by a server older than 26.9 is the
only record of where its `.bin` files were meant to be sent (`DistributedAsyncInsertHeader`
does not store the destination address). A downgrade or a manual recovery could no longer
replay them.

The old name is now written to a file `original_name` inside the directory before the
rename. The directory itself is still renamed to a hash, because the old name may contain
a password and the new name is logged and shown.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread src/Storages/StorageDistributed.cpp Resolved
Comment thread src/Storages/StorageDistributed.cpp Resolved
…ng a spool directory

The rename to `unrecognized_<hash>`, the write of the `original_name` file, and the
removal of such directories on `TRUNCATE TABLE` now run under the directory sync guard
(`IDisk::getDirectorySyncGuard`) when `fsync_directories` is set, like the rest of the
async-insert spool. `test_invalid_shard_directory_format` runs with both values of the
setting; the password in its old-style directory name is unique per run, because
`system.text_log` keeps the queries of the earlier run that mention it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Pushed 2c48227, which addresses the latest AI review:

  • Major (fsync_directories): adopted. The quarantine rename, the original_name write and the removal of unrecognized_* directories on TRUNCATE TABLE now run under the directory sync guard. test_invalid_shard_directory_format runs with the setting both off and on. test_distributed_format passed 9/9 locally on a fresh build.
  • Blocker (queue name vs. current internal_replication): declined, with reasons on the thread. Master already resolves shardN_all_replicas / shardN_replicaM this way no matter which mode the shard is in now, and this PR does not change that. The suggested check would quarantine those queues, and quarantined files are never sent. Delivery that goes to the wrong fan-out would turn into silent data loss. If queues should follow the current mode, for example by re-splitting them after the config changes, that needs its own design and its own PR. A human reviewer should confirm this call.

Comment thread src/Core/Settings.cpp Resolved
Comment thread src/Storages/StorageDistributed.cpp Resolved
…distributed-parts-names

Master moved settings history records into `Settings.cpp` (per-setting records in `DECLARE` / `MAKE_OBSOLETE`).
Took master's `SettingsChangesHistory.cpp`, dropped the `DECLARE` of `use_compact_format_in_distributed_parts_names`,
and moved its history (21.1 record plus the 26.10 obsolete record) onto its `MAKE_OBSOLETE` entry.
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master (21488c598f4e): master moved settings history into Settings.cpp, so the obsolete record for use_compact_format_in_distributed_parts_names now lives on its MAKE_OBSOLETE entry. The touched TUs compile. Replied to the new bot thread about topology-based quarantine and resolved it. That behavior already exists on master, and quarantining would lose data on a transient config shrink.

Reds on the previous head are unrelated to this PR:

Comment thread src/Storages/StorageDistributed.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

Acknowledged. No fix is in progress for lazy_final_early_exit_limit yet (#122479 pinned only the fixture of the sibling lazy_materialization_final_limit). On 1d3a7cac the new server read 31% more rows than the old one for both queries from the same 16 parts (4.25M vs 3.25M for #0, 5.22M vs 3.98M for #1). I'm investigating it and will follow up here with a PR (or my findings).

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. Each fill insert of lazy_final_early_exit_limit writes 8 parts whose key ranges depend on thread timing, so the two compared servers build different tables. On 1d3a7cac both had 16 parts, but not the same ones (1957 vs 1958 marks; my previous comment wrongly said the same 16 parts), and the new server read 31% more rows before #0/#1 reached their LIMIT. Master shows the same shift between near-identical builds (d122a9ff658f: #1 +21.5% rows, +17.2% time). Fixing PR #122660 (mine, open): each insert now writes exactly one part, checked by a throwIf in the fill.

Address review: `sipHash128String` is an unkeyed hash, so `unrecognized_<hash>`
was a stable verifier of the old directory name, which may contain a password
(`user:password@host:port`), and allowed offline brute force of it from the
log or the directory listing. The old name is kept in `original_name`, so the
visible name does not need to be derived from it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Pushed 19231f1bb70e: quarantined spool directories are now named with a random UUID instead of an unkeyed hash of the old name (the review thread is resolved). The changed TU compiles. @groeneai, thanks for the investigation. lazy_final_early_exit_limit will be tracked in #122660, which is unrelated to this PR.

huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Sep 28, 2026
Each fill INSERT squashes the numbers_mt stream in the order the SELECT
threads deliver its 65409-row blocks and cuts a part once
min_insert_block_size_rows (1048449) rows have accumulated, i.e. every 17
blocks, so each INSERT writes 8 parts whose key ranges depend on thread
timing. perf.py fills both servers at the same time and merges stay
stopped, so the two servers of a comparison measure different 16-part
tables for the whole test. Queries #0 and ClickHouse#1 stop at their LIMIT and read
a layout-dependent number of rows: on ClickHouse#120186 the new server read 31%
more rows for both, and the dashboard gate reported +17.9% and +19.3% as
confirmed regressions.

Both INSERTs now set min_insert_block_size_rows = 10000000 (above the
8000000 rows of an INSERT) and min_insert_block_size_bytes = 0 (an INSERT
is ~350 MB, so the 256 MiB default would still cut it in two). Each INSERT
becomes one block, sorted by the key when written, so both servers get the
same two intersecting parts, the fixture the test was measured with. A
throwIf fill query fails the test if the table does not have exactly 2
active parts. max_insert_threads cannot do this: it only fans the squashed
blocks out to the insert sinks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 1, 2026
Merged via the queue into master with commit f58219d Oct 1, 2026
149 checks passed
@alexey-milovidov
alexey-milovidov deleted the remove-non-compact-distributed-parts-names branch October 1, 2026 02:02
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@tavplubix @alexey-milovidov — title/description suggestions:

Description (currently missing):

  • Why: The body is the template plus the title overflow. A reviewer cannot tell from it what happens to an existing non-compact queue on upgrade, or what it means for a rollback.

  • Suggested addition:

    • use_compact_format_in_distributed_parts_names is obsolete and ignored, and the queue is always shardN_replicaM / shardN_all_replicas.
    • On attach, a non-empty subdirectory with any other name is renamed to unrecognized_<UUID>, and its old name goes to original_name. Its files are no longer sent.
    • TRUNCATE TABLE removes unrecognized_* directories.
    • system.distribution_queue.data_path is no longer masked, because no queue name can contain credentials now.
    • Upgrade: if the setting was 0, drain the queue first. Rollback: rename unrecognized_* back (or delete them) before starting an older server. Otherwise the older server cannot attach the table.

Ignore if intentional.

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

Labels

comp-distributed Distributed table engine & query routing across shards (sharding/load balancing). pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants