Repository navigation
TCP: report the driver version, not 0.0.0, so distributed queries work - #725
Conversation
The TCP client reported client version 0.0.0 in its Hello and in the ClientInfo of every query: the version fields were never set, and the patch was written as a literal 0. It also sends query_kind InitialQuery, so the server does not fill in its own version. A server refuses to send a distributed query on when the initiator version is 0.0.0, so clusterAllReplicas, remote() and Distributed tables failed with "Sending a distributed query with unknown (zero) client version". On ClickHouse Cloud this broke every system.query_log lookup in the TCP suite's cancellation tests. The client now reports this package's version (major, minor, patch) from the assembly's informational version, as clickhouse-go reports its own. A build with no usable version, or with 0.0.0 (benchmark builds), reports 1.0.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI review gate — AI review passedClean review from: Cursor Bugbot. |
- A wire test writes ClientInfo with version 12.34.56 and reads the three fields back. A dev build reports 1.0.0, so a dropped minor or patch did not show in the other tests. - ClientVersion.Fallback is a property, so Current does not depend on the order of the static fields. - The remote() test asks the server for its native port. - The changelog entry names the server versions that refuse 0.0.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🟡 Changes recommended
The server-visible client identity change lacks required client documentation explaining package-version reporting and the 1.0.0 fallback.
1 open issue
What changed in this PR
Fixes distributed-query failures in the native TCP client by reporting the driver version instead of 0.0.0. The HTTP client is unchanged.
Changes:
- Reads the assembly version, falling back to
1.0.0for missing, invalid, or zero versions. - Reports major/minor in the handshake and major/minor/patch in per-query metadata.
- Adds parsing, wire-format, distributed-query, and query-log tests, plus a changelog fragment.
| File | Description |
|---|---|
ClickHouse.Driver.Tcp/Protocol/ClientVersion.cs |
Resolves the driver version and nonzero fallback. |
ClickHouse.Driver.Tcp/Protocol/ClientMetadata.cs |
Retains the patch version for query metadata. |
ClickHouse.Driver.Tcp/Protocol/ClientInfo.cs |
Writes the patch version instead of zero. |
ClickHouse.Driver.Tcp/Protocol/ClientHandshakeParameters.cs |
Defaults version fields to the driver version. |
ClickHouse.Driver.Tcp.Tests/Protocol/ClientVersionTests.cs |
Tests parsing, fallback, defaults, and wire encoding. |
ClickHouse.Driver.Tcp.Tests/Integration/ClientVersionIntegrationTests.cs |
Tests distributed execution and server-recorded versions. |
changelog.d/725-tcp-client-version.fixes.md |
Documents the distributed-query fix. |
Review effort: Balanced
| /// The client version the driver reports in its handshake and in the ClientInfo of every query: the version of this | ||
| /// package, as major, minor and patch. |
There was a problem hiding this comment.
Added in 04bc611: a new section "Client name and version on the server" under "Logging and diagnostics" in docs/tcp.mdx. It lists the system.query_log / system.processes columns, says the version is the ClickHouse.Driver package version, and gives the 1.0.0 fallback with its reason.
There was a problem hiding this comment.
Automated approval by the AI review gate.
The required AI review gate concluded SUCCESS on 1b0c0a5, and this change touches no path that requires a human reviewer. This approval is posted by an automated identity (security-ai-gate-reviewer[bot]), not a human, and is bound to the evaluated commit. A new push dismisses it and re-evaluates.
repo=ClickHouse/clickhouse-cs pr=#725 head=1b0c0a5a4c991d90f8b281d34492cee3387b3b8f
| { | ||
| /// <summary>The version reported when the build carries no usable one.</summary> | ||
| /// <remarks>A property rather than a field, so <see cref="Current"/> can read it whatever the field order.</remarks> | ||
| internal static (int Major, int Minor, int Patch) Fallback => (1, 0, 0); |
There was a problem hiding this comment.
The root AGENTS.md requires public behavior changes to be documented in docs/tcp.mdx in the same PR, but that page is unchanged. Users inspecting system.query_log or system.processes now see the driver version, and a build with a missing, invalid, or zero version reports 1.0.0; the changelog does not explain that fallback. Add a short note under Logging and diagnostics describing the version fields, their package-version source, and the fallback so users can interpret these values correctly.
A reply here is read on the next review: an explanation that holds up drops the finding.
There was a problem hiding this comment.
Added in 04bc611: a new section "Client name and version on the server" under "Logging and diagnostics" in docs/tcp.mdx. It lists the system.query_log / system.processes columns, says the version is the ClickHouse.Driver package version, and gives the 1.0.0 fallback with its reason.
|
Summary
|
The TCP page now says which client name and version ClickHouse shows in system.query_log and system.processes, where the version comes from, and when the client reports 1.0.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Automated approval by the AI review gate.
The required AI review gate concluded SUCCESS on 04bc611, and this change touches no path that requires a human reviewer. This approval is posted by an automated identity (security-ai-gate-reviewer[bot]), not a human, and is bound to the evaluated commit. A new push dismisses it and re-evaluates.
repo=ClickHouse/clickhouse-cs pr=#725 head=04bc611a48c671c1df64a213294a0189ed63e528

Summary
The native TCP client reported client version 0.0.0 in its handshake and in the ClientInfo of every query. A ClickHouse server refuses to send a distributed query on to another server when the client that started it reports 0.0.0. So
clusterAllReplicas,remote()andDistributedtables failed through this client:Why the client sent 0.0.0.
ClientHandshakeParameters.VersionMajorandVersionMinorwere never set, andClientInfowroteclient_version_patchas a literal0. The client also sendsquery_kind = InitialQuery, and the server fills in its own version only for a query that has no query kind (Session.cpp). The check that refuses the zero version is inRemoteQueryExecutor.cpp.What changes. The client reports this package's version (major, minor, patch) in the Hello and in every ClientInfo. It reads the version from the TCP assembly's
AssemblyInformationalVersion, which the release build sets with/p:Version. clickhouse-go does the same with its own version (2.51.0 inclient_info.go). A build whose version is missing, cannot be read, or is 0.0.0 (the benchmark builds use0.0.0-baselineand0.0.0-pr.N) reports 1.0.0 instead.How this was found.
StreamAsync_CancelledMidResult_StopsTheQueryOnTheServerandStreamAsync_EnumerationAbandonedEarly_StopsTheQueryOnTheServerfail in the Cloud TCP job onmainand on #724. Both readsystem.query_logthroughclusterAllReplicas(default, ...). On a Cloud service the other replicas are remote, so that read is a distributed query. The tests were right; the client was wrong. On the local test container the same lookup reads the local node only, which is why the regular matrix never saw it.Tests
ClientVersionIntegrationTests.ExecuteScalarAsync_RemoteQueryToTheSameServer_Succeedsrunsremote('localhost:9000', system.one, ...)withprefer_localhost_replica = 0, so the local container takes the remote path. Onmainit fails with the same error as Cloud; with this change it passes.ExecuteScalarAsync_QueryThatReadsEveryCloudReplica_Succeeds(Cloud only) runsclusterAllReplicas(default, system.one).ExecuteAsync_AnyQuery_RecordsTheDriverVersionAsTheClientVersionreadsclient_version_major/minor/patchfromsystem.query_log.ClientVersionTests: parsing of1.5.0+hash,1.4.0-rc2+hash,0.0.0-baseline, empty and unparsable versions, and the handshake defaults.ClickHouse.Driver.Tcp.Testson net8.0, net9.0, net10.0: 4199 passed, 1 skipped (the Cloud-only test), 0 failed.mainat c8f641a: 4186 passed.main.Checklist
🤖 Generated with Claude Code
Note
Medium Risk
Touches native protocol handshake and per-query ClientInfo metadata used by distributed query routing; behavior change is intentional but affects all TCP connections.
Overview
Fixes distributed queries failing on ClickHouse 26.8+ because the native TCP client advertised 0.0.0 in the handshake and every query’s
ClientInfo. The driver now derives major/minor/patch from the assembly informational version via a newClientVersionhelper, defaults handshake metadata to that value, and writes the patch on the wire instead of a hard-coded zero; unusable or 0.0.0 builds fall back to 1.0.0.Adds unit tests (parsing, wire layout, handshake defaults), integration tests (
remote,clusterAllReplicas,system.query_logcolumns), a changelog entry, and TCP docs on howclient_name/ client version appear on the server.Reviewed by Cursor Bugbot for commit 04bc611. Bugbot is set up for automated code reviews on this repo. Configure here.