Skip to content

Do not use inactive replicas as make_distributed_plan workers - #130917

Merged
davenger merged 7 commits into
masterfrom
distributed-plan-skip-inactive-workers
Nov 18, 2026
Merged

davenger merged 7 commits into
masterfrom
distributed-plan-skip-inactive-workers

Conversation

@davenger

@davenger davenger commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

A make_distributed_plan query that takes its workers from a cluster used every registered replica, also a replica that is stopped. A task sent to such a replica fails the whole query, e.g. with Connection refused, and each new query fails in the same way while the replica stays registered.

Now the worker list does not include the replicas that the cluster reports as inactive. It is the same is_active data that system.clusters shows and that parallel replicas use, so it applies to the clusters that have it, e.g. the cluster of a Replicated database.

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 into CHANGELOG.md):

Fix make_distributed_plan queries that failed when a replica of the worker cluster was stopped but still registered in the cluster. Such a replica no longer gets tasks.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2723-master (included in 26.11 and later)

@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5f90461]

Summary: ✅


AI Review

Summary

The PR excludes inactive replicas from make_distributed_plan worker allocations, shares one worker snapshot between planning and execution, and refreshes liveness in the background. The four previous bot findings are addressed in the current code; no new actionable findings remain.

Missing context / blind spots
  • ⚠️ The current head’s targeted integration and unit jobs are pending, and no local ClickHouse binary is available. On commit a31370637, the stop/restart regression passed both the targeted integration job and bugfix validation, and the cluster-name replacement unit test passed. Current-head CI will complete runtime validation after the merge from master.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Nov 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 5f9046149 with master 7074838a9 (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

6 object files changed (+23.38 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Server/StatelessWorker/StaticStatelessWorkersProvider.cpp.o 112.62 KiB 135.55 KiB +22.93 KiB (+20.36%)

711 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

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

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-distributed Distributed table engine & query routing across shards (sharding/load balancing). label Nov 11, 2026
@davenger
davenger requested a review from serxa November 12, 2026 09:28

@serxa serxa 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.

I think factory rework is not justified here. Replica liveness is better to be part of some runtime state checked during allocate() calls, rather than configuration. Then signature-related stuff may stay as it is now.

@davenger

Copy link
Copy Markdown
Member Author

Agreed on the factory: I will remove that change, and the signature will be configuration only again.

One constraint on allocate: the optimizer asks the provider for the node count (getPlanningNodeCount) before the executor calls allocate. If only allocate checks liveness, a query is planned for all configured replicas and runs on fewer of them during each replica restart. So I propose to read the liveness one time, when the query context gets its provider, and to use that list for the node count and for allocate. The registry and the factory stay as they are on master.

@davenger
davenger requested a review from serxa November 13, 2026 18:45

@clickhouse-gh clickhouse-gh Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review approves this commit, see the AI Review comment.

@serxa serxa 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.

Sorry, I lost the notification. The code looks good!

@davenger
davenger added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit 03cf0c4 Nov 18, 2026
193 checks passed
@davenger
davenger deleted the distributed-plan-skip-inactive-workers branch November 18, 2026 14:50
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 18, 2026
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-bugfix Pull request with bugfix, not backported by default 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.

3 participants