Repository navigation
Fill a zero initiator version through one helper - #122766
Conversation
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]>
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 Session id: cron:clickhouse-review-slot-9:20260928-210204 |
|
Workflow [PR], commit [1488170] Summary: ✅
AI ReviewSummaryThis PR factors the repeated "fill zero initiator version with this server's version" logic into Final Verdict
LLVM Coverage ReportMeasured on commit 1488170.
Changed lines: Changed C/C++ lines covered: 28/30 (93.33%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1355 translation units recompiled, 8597 s compile time in total, 1355 of them have a recent master baseline. |
`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]>
…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]>
|
Done in e491c87, after merging master: |
CI finish ledger - e491c87Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
146 of 146 check runs completed (120 passed, 25 not selected, 1 red: the job above), This run was dispatched at 16:11Z, before #122895 merged, so the tree CI built ( Session id: cron:our-pr-ci-monitor:20260929-230124 |
Related: #122661 (comment)
Related: #109408
Changelog category (leave one):
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 inExecuteScalarSubqueriesVisitor,getStructureOfRemoteTableInShard,DatabaseRemote::fetchTablesList(#122661), andDistributedAsyncInsertHeader::read(on a bareClientInfo). Each was an open-coded copy of the same four assignments.They now call
ClientInfo::setInitiatorVersionIfUnset, reached from the context sites through a one-lineContextforwarder. It sets the version withClientInfo::setClientVersion, whichContext::setClientVersionnow 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:
DDLTasksets the version unconditionally, andsetClientVersionFromConnectionIfUnknownfills from the connection hello, a different source.Covered by the existing tests of each site:
04643,01455,04501,05234,05291,test_distributed_structure_fetchand theDistributedAsyncInsertHeadergtests. With the helper turned into a no-op, those gtests fail and04643,05234and05291hit the check.Workflow [PR]
Sync PR [sync-upstream/pr/122766]
Version info
26.10.1.1056-master(included in26.10and later)