Repository navigation
Conversation
The initiator's server-side `Connection` (RemoteQueryExecutor, RemoteInserter, the Distributed async queue) never takes format settings, so it always reads and writes `Native` blocks with textual type names. Since fa40b43 `TCPHandler` builds its wire `NativeWriter` and `NativeReader` from the query's format settings, and a secondary query carries the initiator's settings. With `output_format_native_encode_types_in_binary_format = 1` the shard wrote binary-encoded types that the initiator parsed as names (`SYNTAX_ERROR`, or `UNKNOWN_CODEC` for `Dynamic`, whose type index is read as a 43-byte length); with `input_format_native_decode_types_in_binary_format = 1` the shard parsed the initiator's blocks, including the empty external-tables block of every remote SELECT, as binary types (`CORRUPTED_DATA`). `TCPHandler` now clears both flags in the wire format settings of a `SECONDARY_QUERY`, at all six sites. The query context is unchanged, so a shard still applies the settings to formats it reads or writes itself (`remote(..., file(..., Native))`); stripping them on the sender side in `ClusterProxy::stripInitiatorOnlySettings` would break exactly that. This is the cause of the `04819_dynamic_aggregate_function_state_version` failures in the ParallelReplicas coverage lane (issue ClickHouse#116341 read it as a teardown race): the 4th fetch is the only one with the encode flag, and it fails whenever a remote replica's packet is read before the local plan finishes. The Native format and protocol specs are updated, and the new test 05317_native_binary_types_between_servers covers remote read, parallel replicas, remote insert and a shard-side file() read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit made `TCPHandler` ignore both binary type encoding flags for the wire of a `SECONDARY_QUERY`, but `clickhouse-client --query_kind secondary_query` still configured its own `Connection` from them. With both flags set that query worked before (both ends binary) and desynchronized after (server names, client binary): `CORRUPTED_DATA` on INSERT and SELECT. The rule now lives in one function, `getNativeWireFormatSettings`, used by the six `TCPHandler` wire sites and by both places where the client configures its `Connection`. The client's own input and output formats keep honouring the flags. The spec text states the symmetric rule. 05317 becomes a shell test so it can send a secondary query from the client; that part is green on master and red on the server-only fix, while the server-to-server parts stay red on master. The parallel replicas leg now pins `automatic_parallel_replicas_mode = 0`, which the runner randomizes to 2 (statistics only, no parallel read) in a quarter of the runs, and checks `ParallelReplicasUsedCount`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A secondary query's `Native` blocks carry type names only when both peers are at `DBMS_MIN_REVISION_WITH_TYPE_NAMES_FOR_SECONDARY_QUERY` (54493). `getNativeWireFormatSettings` takes the peer's revision: `TCPHandler` passes the client revision from the hello, `clickhouse-client` the server revision it got from `getServerVersion`. A peer built before this change honours both binary type encoding settings for a secondary query, so the unfenced rule broke `clickhouse-client --query_kind secondary_query` with both flags between an old and a new binary in either direction. With the fence every pairing with an older peer behaves as on master; an old initiator with a new shard keeps the master error. Bump `DBMS_TCP_PROTOCOL_VERSION` to 54493 and document the revision in the native protocol and format specs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`processParsedSingleQuery` set the Native wire format settings on the client `Connection` before the reconnect check. A reconnect replaces the object, and the replacement starts with no format settings and with the server revision it has only just learned, so the first query on it ignored both binary type encoding flags: the result failed with `SYNTAX_ERROR` (same order on master for any query kind). The call now runs after the check; nothing in between reads the format settings. The parallel replicas leg of 05317 pins `enable_parallel_blocks_marshalling = 1`, which the runner disables in 5% of the runs, so the step that reaches the two block-marshalling callbacks is always planned. New `test_backward_compatibility/test_native_type_names_secondary_query` runs `clickhouse-client --query_kind secondary_query` with both flags from a 25.3 client against this server and the reverse; it fails in both directions when the revision check in `getNativeWireFormatSettings` is removed. The Native format spec lists the revision in its gate table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The parallel replicas leg of 05317 read through `test_cluster_one_shard_three_replicas_localhost`, whose 127.0.0.1 replica is a local address and so gets an uncompressed connection (`Cluster.cpp`, `compression` defaults to `!is_local`). Without a codec `convertColumnsToBLOBs` returns the block unchanged, so when the coordinator gave the granule to that replica no BLOB was made and the block-marshalling callback was not checked. The leg now uses the `parallel_replicas` cluster with `max_parallel_replicas = 2` and `load_balancing = 'in_order'`: that cluster lists 127.0.0.2 and 127.0.0.3 first, with fewer replicas than the cluster has the pools are ordered by `load_balancing` on `(error_count, priority, ...)`, and `distributed_replica_max_ignored_errors = 1000` keeps an error count left by another test from moving 127.0.0.1 ahead. Both used replicas are non-local, so whichever reads the granule compresses and marshals it. Shell tests run with `--send_logs_level=warning` and no query of 05317 made the shard log a warning, so no Log block crossed the shard wire. A new part runs the `remote()` read with `send_logs_level = 'trace'` and `--server_logs_file`, so the shard's Log blocks travel to the initiator. The protocol spec row for revision 54493 also names Totals and Extremes blocks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server sends the user's profile settings in Hello, and the client applies the ones it did not change itself to its context in `applySettingsFromServerIfNeeded`. That ran one line after the client configured its `Connection` from the same context, and the per-query snapshot is restored afterwards, so the Native wire flags of a profile never reached the `Connection`: with both binary type encoding flags in the profile, the server wrote and read binary-encoded types while the client used type names, and every `clickhouse-client` query failed with `Code: 62` (same order on master). Swap the two calls. 05317 gains a part with both flags set on a user; it fails on master and on the previous head, passes now, and fails again with `--apply_settings_from_server 0`. The revision-table rows in protocol.mdx and format.mdx now say that below 54493 a server never applies these settings to its own connection, so between servers the shard and the initiator disagree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ction Configure the client's Connection with the Native wire settings before the settings sent by the server are applied, as on master. The server writes type fields with output_format_native_encode_types_in_binary_format and the client reads them with input_format_native_decode_types_in_binary_format, so the two flags of a user profile must not reach the Connection one by one: a profile with only the input flag would make the client read every server block as binary types while the server sends type names. 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; 15 findings over 8 rounds) plus my own cold review (nits). Bounce cap reached: published as is after the final fix round, with no gate run on this head; residual findings are listed below as not blocking. The final round restored the round 4 client and test files, which the gate reviewed (#11, #12), and kept the spec wording of #12. After publication, a gated round fixed #13 (raised again by the automated review) and #18.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261003-040700, post-publication round: cron:clickhouse-maint-slot-13:20261003-060200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261003-032400 |
|
Workflow [PR], commit [46f121b] Summary: ✅
AI ReviewSummaryReviewed the current PR diff, the prior discussion, and the resulting code paths for client/server Final Verdict✅ No new blocking or major findings. LLVM Coverage ReportMeasured on commit 46f121b.
Changed lines: Changed C/C++ lines covered: 52/58 (89.66%) · Uncovered code |
Build profile diff (arm_release)Commit See the job log for details. |
…g settings In cluster mode `QueryRunner` sends each job as an initial query over a server-side `Connection`, which never takes format settings and so always reads and writes type names. The remote server runs the job as an ordinary initial query, so it applies `output_format_native_encode_types_in_binary_format` and `input_format_native_decode_types_in_binary_format` from the job's settings to the wire. A job with the output flag set was therefore logged on the initiator as failed with `Code: 62` (`Syntax error (data type)`) while the remote finished it, on master as well. The connection now takes the job's format settings with the two flags swapped: it reads with the flag the remote writes with, and writes with the flag the remote reads with. Taking them unswapped, as `clickhouse-client` does, would break a job that sets only the input flag, which works today (measured: `Code: 246` for it). The remote side is unchanged, so this also works against servers without this change. 05317 gains a part with three jobs (both flags, output only, input only) on a `QueryRunner` table over `test_shard_localhost`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Scalars go through the same writer as Data blocks (`Connection::sendData`) and are read by `TCPHandler::initBlockInput`, so the revision 54493 rule covers them too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 6f44aacEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 157 check runs completed and Session id: cron:our-pr-ci-monitor:20261003-143124 |
|
Fixing PR for 05257_sql_security_view_sealed (parallel replicas) created: #123729 |
|
Fixing PR for 05237_with_expression_alias_scope_descendant (DBReplicated): #123774 |
…ad path `TCPHandler::processUnexpectedData` read the blocks it discards with default format settings, while the main read path (`initBlockInput`) decodes them with `getNativeWireFormatSettings`. A peer encodes its `Data` packets the same way whether the server reads or skips them, so with `output_format_native_encode_types_in_binary_format` and `input_format_native_decode_types_in_binary_format` both set, a query that failed before its external data was read made the skip reader take a binary type code for a type name. The server then closed the connection, and the client reported `Connection reset by peer` instead of the query's error. Route the skip reader through the same helper, so it decodes exactly what the main reader would. 05317 gets a part that sends external data with both flags and fails the query server-side with `max_ast_elements`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-query rule The FLATTENED Dynamic layout snippet still said its per-type names switch to a binary type encoding whenever output_format_native_encode_types_in_binary_format = 1. At revision 54494+ a secondary query writes them as textual names, like the column type field (SerializationDynamic reads the same wire format settings). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… out QueryRunner Review on ClickHouse#123649: with the revision check an old initiator talking to a new shard keeps the old error; without it a new shard also works with an old initiator, because a server-side Connection never takes format settings and always reads and writes type names. This fixes rolling upgrades. The cost is `clickhouse-client --query_kind secondary_query` with these settings between an old client and a new server. The integration test now runs a 25.3 initiator against a new shard with both settings (fails on master with Code 62). The QueryRunner cluster connection change goes to a separate PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Fixing PR for the arm_release 5/6 perf red (sum_map #0): #124676 |
Cherry pick #123649 to 26.9: Fix distributed queries failing when Native binary type encoding is enabled
Cherry pick #123649 to 26.8: Fix distributed queries failing when Native binary type encoding is enabled
… binary type encoding is enabled
… binary type encoding is enabled
Backport #123649 to 26.9: Fix distributed queries failing when Native binary type encoding is enabled
Backport #123649 to 26.8: Fix distributed queries failing when Native binary type encoding is enabled
The bugs behind their `no-parallel-replicas` / `no-replicated-database` tags are fixed on master: - `01660_join_or_any`: ClickHouse#123683 - `04653_bloom_filter_fixed_string_constant_scalar`: ClickHouse#118988 - `04819_dynamic_aggregate_function_state_version`: ClickHouse#123649 - `04825_quantile_deterministic_alter_add_modify_column`: ClickHouse#115393, ClickHouse#123070 - `04494_atomic_populate_materialized_view_parallel_replicas`: ClickHouse#124477 - `04266_text_index_tokens_cardinality_order`: ClickHouse#124500 already disables parallel replicas for the log-checked query Related: ClickHouse#124015
The change is taken as in the original (1a44640, #130895), with the adaptations below. Adapted: - `src/Formats/NativeReader.h`, `src/Formats/NativeReader.cpp`: the new `allowed_kinds_` parameter and the `allowed_kinds(allowed_kinds_)` initializer go after `block_missing_values_`, without the master-only `type_cache_` (`NativeReaderTypeCache`, #129831). The branch keeps its own `format_settings_ = std::nullopt` default. - `src/Processors/Formats/Impl/NativeFormat.cpp` (`makeReader`): the `/*type_cache_=*/ nullptr,` argument is dropped. The file merged without a conflict, but would not compile as merged. - `src/Server/TCPHandler.cpp`: the original only adds the `ISerialization::KindSet{ISerialization::Kind::DEFAULT}` argument; `getNativeWireFormatSettings` (#123649) is on its context lines and is not on the branch. `skipDataPacket` passes no format settings here, so an explicit `std::nullopt` stands in that position. `initBlockInput` keeps `getFormatSettings(state.query_context)`, with an explicit `nullptr` for `block_missing_values_` and without `type_cache_`. Both comments of the original are kept. - `src/Interpreters/AsynchronousInsertQueue.cpp`: `IColumn::convertToFullIfWrapped` (#107773) is not on the branch, and `convertToFullIfNeeded` also strips `LowCardinality`. The check uses a file-local `hasWrappedColumn` instead: a `ColumnBLOB`, `ColumnConst`, `ColumnReplicated` or `ColumnSparse` at any nesting depth, `LowCardinality` left alone, nothing converted. The exception and its message are as in the original. The only producers of `pushQueryWithBlock` on the branch are the two calls in `TCPHandler::processAsyncInsertQuery`: a header without columns, and the squashed blocks that `initBlockInput` reads, which now accepts only the default kind. Left out: - `tests/queries/0_stateless/04616_replicated_serialization_oob_index_native_protocol.python` and `.reference`: the scenarios the branch does not have: invalid index type size, index row count mismatch, sparse over replicated (#114186) and huge element count (#129932). The rewrite of the two existing scenarios and the new `replicatedTupleElementScenario` and `replicatedOnInsertScenario` are kept, with their reference lines. - `tests/queries/0_stateless/05473_sparse_truncated_values_native_protocol.python`, `.reference`, `.sh`: the original only edits this test, and it comes from #128363, which is not on the branch (modify/delete conflict). - `docs/resources/develop-contribute/native-protocol/format.mdx`: the branch has no English specification of the `Native` format, so the hunks have nowhere to go (modify/delete conflict). `tests/queries/0_stateless/helpers/fake_native_server.py` is as in the original here. It does not work with the client of this branch, which sends a `Ping` before each query; the next commit adapts it. Everything else merged without conflicts and has the same changed lines as the original. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Closes: #123991
Related: #116341
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed queries that go through another server (
remote,Distributed, parallel replicas,GLOBAL IN) failing withSYNTAX_ERROR,UNKNOWN_CODECorCORRUPTED_DATAwhenoutput_format_native_encode_types_in_binary_formatorinput_format_native_decode_types_in_binary_formatis enabled. The blocks of these queries now carry type names on the wire, and a shard with this change also works with an initiator without it.clickhouse-client --query_kind secondary_queryfollows the same rule.Description
On 26.8.10.6 and 25.3.14.14,
SELECT * FROM remote('127.0.0.2', system.one)withoutput_format_native_encode_types_in_binary_format = 1fails withCode: 62(Syntax error (data type)); the decode flag alone givesCode: 246 CORRUPTED_DATAfrom the shard.TCPHandlerbuilds its wireNativeWriter/NativeReaderfrom the query's format settings. The initiator's server-sideConnectionnever takes format settings and always uses type names, but a secondary query carries the initiator's settings, so the shard writes and parses binary-encoded types. Now one function, used byTCPHandlerand by the client'sConnection, clears both flags for the wire of aSECONDARY_QUERY. It is not gated on the protocol revision, so a new shard also works with an old initiator during a rolling upgrade; the cost is thatclickhouse-client --query_kind secondary_querywith these settings no longer works between different client and server versions. A shard still applies them to formats it reads itself. The client now also configures itsConnectionafter a reconnect. Data the server skips after an error is decoded by the same rule, so a client query with external data no longer getsConnection reset by peerinstead of its error.This causes the
04819_dynamic_aggregate_function_state_versionfailures in the ParallelReplicas jobs, e.g. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=68493&sha=580775c4b5032d7f02cb49cf35c8c48419cb4b4d&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 .Validation: new test
05317_native_binary_types_between_serverscoversremoteread/insert/logs, parallel replicas, shard-sidefile(), a client secondary query and skipped external data; it fails on master.test_native_type_names_secondary_queryruns a 25.3 initiator against a new shard.04819: 50/50 in the ParallelReplicas profile.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123649]
Version info
26.10.1.1890-master(included in26.10and later)26.9.18.12,26.8.26.11