Skip to content

Fill a zero initiator version through one helper - #122766

Merged
PedroTadim merged 6 commits into
ClickHouse:masterfrom
groeneai:initiator-version-helper
Sep 30, 2026
Merged

PedroTadim merged 6 commits into
ClickHouse:masterfrom
groeneai:initiator-version-helper

Conversation

@groeneai

@groeneai groeneai commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122661 (comment)
Related: #109408

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Description

Seven places fill a zero client version with this server's version before a distributed sub-query can reach the check in RemoteQueryExecutor::sendQueryUnlocked (#109408): Context::makeQueryContext, Session::makeQueryContextImpl, StorageMaterializedView::createRefreshContext, the scalar subquery context in ExecuteScalarSubqueriesVisitor, getStructureOfRemoteTableInShard, DatabaseRemote::fetchTablesList (#122661), and DistributedAsyncInsertHeader::read (on a bare ClientInfo). Each was an open-coded copy of the same four assignments.

They now call ClientInfo::setInitiatorVersionIfUnset, reached from the context sites through a one-line Context forwarder. It sets the version with ClientInfo::setClientVersion, which Context::setClientVersion now forwards to. The check itself still throws; its comment now points to the helper and says not to fill the version there. No behavior change.

Not converted: DDLTask sets the version unconditionally, and setClientVersionFromConnectionIfUnknown fills from the connection hello, a different source.

Covered by the existing tests of each site: 04643, 01455, 04501, 05234, 05291, test_distributed_structure_fetch and the DistributedAsyncInsertHeader gtests. With the helper turned into a no-op, those gtests fail and 04643, 05234 and 05291 hit the check.


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

Version info

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

groeneai and others added 2 commits September 28, 2026 19:48
Six places open-coded the same fill of a zero client version with this
server's version: `Context::makeQueryContext`, `Session::makeQueryContextImpl`,
`StorageMaterializedView::createRefreshContext`, the scalar subquery context in
`ExecuteScalarSubqueriesVisitor`, `getStructureOfRemoteTableInShard` and
`DistributedAsyncInsertHeader::read` (on a bare `ClientInfo`). Each copy was
added after the zero-version check in `RemoteQueryExecutor::sendQueryUnlocked`
(ClickHouse#109408) fired for another server-built context, and each repeated the same
rationale in its comment.

Move the logic into `ClientInfo::setInitiatorVersionIfUnset` (next to its
sibling `setClientVersionFromConnectionIfUnknown`), add a one-line
`Context::setInitiatorVersionIfUnset` forwarder for the context sites, and
keep only the site-specific sentence at each call site. The protocol version
is still set unconditionally together with the three version fields, exactly
as every copy did, so there is no behavior change.

The check in `RemoteQueryExecutor` still throws. Its comment now points to
the helper and says not to fill the version there, because the check exists
to catch a context that lost it. The stale "whether to enable the analyzer"
example is dropped: the old analyzer is gone.

Not converted on purpose: `DDLTask` sets the version unconditionally (this
host re-initiates the DDL), and `setClientVersionFromConnectionIfUnknown`
fills from the connection hello, a different source. The same fill in
`DatabaseRemote::fetchTablesList` comes with ClickHouse#122661, which is not merged
yet, and moves to the helper once it is.

Includes that the original fills added only for `VERSION_*` and
`DBMS_TCP_PROTOCOL_VERSION` are removed.

Requested in ClickHouse#122661 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the setInitiatorVersionIfUnset doc comment to the invariant it implements; the RemoteQueryExecutor check and the no-op case are covered by the check's own comment and the name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-review-human PR origin: human review feedback on a groeneai PR labels Sep 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex): 0 findings. My own cold review, done before reading the implementation's evidence, found no blocker or major: each of the six sites checks and fills the same object at the same point as before. The one site where master read a different object is createRefreshContext, which checked its local client_info copy; refresh_context->setClientInfo(client_info) makes the two identical, and nothing in between writes a version field.

Session id: cron:clickhouse-review-slot-9:20260928-210204

@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1488170]

Summary: ✅


AI Review

Summary

This PR factors the repeated "fill zero initiator version with this server's version" logic into ClientInfo::setInitiatorVersionIfUnset, rewires the seven existing call sites to use it, and leaves the intentionally different connection-hello and unconditional DDLTask paths separate. I did not find a correctness, compatibility, or test-coverage regression in the current head.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 1488170.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.60% 79.60% +0.00%

Changed lines: Changed C/C++ lines covered: 28/30 (93.33%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 28, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-distributed Distributed table engine & query routing across shards (sharding/load balancing). label Sep 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1488170cb with master 2d590f5bc (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.

Compile time of recompiled translation units

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

Job report

@PedroTadim PedroTadim self-assigned this Sep 29, 2026
Comment thread src/Interpreters/ClientInfo.cpp Resolved
`setClientVersion` existed only on `Context`, and `setInitiatorVersionIfUnset`
is a `ClientInfo` method because `DistributedAsyncInsertHeader::read` fills a
bare `ClientInfo`, so the helper repeated the four assignments. Move them into
`ClientInfo::setClientVersion`: `Context::setClientVersion` forwards to it and
the helper calls it. No behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PedroTadim

Copy link
Copy Markdown
Member

@groeneai #122661 has just been merged. Can you also include that case in this PR's cleanup?

groeneai and others added 2 commits September 29, 2026 15:28
…rough the helper

ClickHouse#122661 added a seventh copy of the fill, in `DatabaseRemote::fetchTablesList`.
It now calls `setInitiatorVersionIfUnset` like the other six, and the two
includes it needed only for `VERSION_*` and `DBMS_TCP_PROTOCOL_VERSION` are
removed. No behavior change.

Requested in ClickHouse#122766 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in e491c87, after merging master: DatabaseRemote::fetchTablesList now calls setInitiatorVersionIfUnset, and the two includes that only the fill needed are removed. 05291_remote_database_without_local_shard passes, and hits the check with the helper turned into a no-op.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - e491c87

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_llvm_coverage, 1/8) / test_storage_iceberg_no_spark/test_iceberg_inverted_manifest_bounds.py::test_iceberg_narrow_manifest_bounds trunk regression, not caused by this PR: master failed it on every run from 2026-09-29 10:59Z until #122895 merged at 16:58Z, and has passed it since. The assertion at line 337 waits for a log line that master no longer writes. This PR only changes how a zero initiator version is filled #122895 (mine, merged), merged master @ 1488170cb4b15
Mergeable Check, PR rollups, red only because of the row above #122895 (mine, merged)

146 of 146 check runs completed (120 passed, 25 not selected, 1 red: the job above), Finish Workflow is green and CH Inc sync passed.

This run was dispatched at 16:11Z, before #122895 merged, so the tree CI built (c8d73eed8dca) does not contain it. I merged master into the branch at 1488170cb4b15, where #122895 is an ancestor. My own change is unchanged across the merge (11 files, +49/-82, same patch id). CI is re-running on 1488170cb4b15.

Session id: cron:our-pr-ci-monitor:20260929-230124

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

Good cleanup

@PedroTadim
PedroTadim added this pull request to the merge queue Sep 30, 2026
Merged via the queue into ClickHouse:master with commit e1ef792 Sep 30, 2026
149 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-distributed Distributed table engine & query routing across shards (sharding/load balancing). groeneai-origin-review-human PR origin: human review feedback on a groeneai PR pr-not-for-changelog This PR should not be mentioned in the changelog 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