Skip to content

Deprecate allow_experimental_query_deduplication feature - #99398

Merged
devcrafter merged 30 commits into
masterfrom
remove-experimental-query-deduplication
Jun 22, 2026
Merged

devcrafter merged 30 commits into
masterfrom
remove-experimental-query-deduplication

Conversation

@devcrafter

@devcrafter devcrafter commented Mar 13, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

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

The change removes allow_experimental_query_deduplication feature. The feature was experimental for a long time, has no tests and not going to be supported (initial tests were unstable and has been removed #49579)

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3872874]

Summary: ❌

job_name test_name status info comment
Stress test (arm_tsan) FAIL
Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-41a5) FAIL cidb, issue

AI Review

Summary

This PR removes the experimental allow_experimental_query_deduplication SELECT path, makes the setting obsolete, and keeps the old PartUUIDs / IgnoredPartUUIDs packet IDs reserved. The removal direction is clear, but there are still mixed-version protocol and resource-safety gaps, so I would request changes before merge.

Findings

⚠️ Majors

  • [src/Client/Connection.cpp:1434] Server::PartUUIDs compatibility handling still caps by UUID count instead of payload bytes. DEFAULT_MAX_STRING_SIZE is 1_GiB, and each UUID is 16 bytes, so a peer can advertise DEFAULT_MAX_STRING_SIZE UUIDs and make the client drain up to 16 GiB before ignoring the obsolete packet. Suggested fix: reject when num_part_uuids > DEFAULT_MAX_STRING_SIZE / sizeof(UUID), or fail closed without draining when preserving framing is not required.
  • [src/Client/ClientBase.cpp:1593] [dismissed by author -- https://github.com/Deprecate allow_experimental_query_deduplication feature #99398#discussion_r2943180929] Connection::receivePacket now returns Protocol::Server::PartUUIDs, but ClientBase::receiveAndProcessPacket falls through to UNKNOWN_PACKET_FROM_SERVER. The reply says the client should never receive this packet, but the old sender emitted PartUUIDs from the ordinary query path when allow_experimental_query_deduplication was enabled, so a newer client can still fail against an older server/profile. Suggested fix: keep the former case Protocol::Server::PartUUIDs: return true; here.
Tests
  • ⚠️ [dismissed by author -- https://github.com/Deprecate allow_experimental_query_deduplication feature #99398#discussion_r2945972856] There is still no focused mixed-version protocol regression test for the obsolete packet contract. Please add the smallest test that proves the chosen rollout behavior: a newer initiator/client handles old Server::PartUUIDs without excessive allocation/draining, and a new server rejects or ignores old Client::IgnoredPartUUIDs exactly as intended.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: cap or fail-close the obsolete Server::PartUUIDs payload by bytes, preserve direct client handling of PartUUIDs if mixed-version compatibility is intended, and add focused mixed-version protocol coverage for the obsolete packet behavior.

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Mar 13, 2026
Comment thread src/Server/TCPHandler.cpp Resolved
The setting is now obsolete (`MAKE_OBSOLETE`), so it should be in the
ignore list rather than `enableAllExperimentalSettings.cpp`.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread src/Client/Connection.cpp Resolved
alexey-milovidov and others added 2 commits March 16, 2026 02:43
It allows execution queries in cluster with previous server versions
with unintentionally enabled allow_experimental_query_deduplication
@devcrafter
devcrafter marked this pull request as ready for review March 16, 2026 20:11
Comment thread src/Client/MultiplexedConnections.cpp Resolved
Comment thread src/Client/HedgedConnections.cpp Resolved
Comment thread src/Client/ClientBase.cpp
@@ -1466,9 +1466,6 @@ bool ClientBase::receiveAndProcessPacket(ASTPtr parsed_query, bool cancelled_)

switch (packet.type)

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.

⚠️ Mixed-version compatibility gap for client/server protocol: Connection::receivePacket still tolerates Protocol::Server::PartUUIDs and returns a packet of that type, but ClientBase::receiveAndProcessPacket no longer handles it and now throws UNKNOWN_PACKET_FROM_SERVER in default.

This can break a newer clickhouse-client against an older server that still emits packet 12 when allow_experimental_query_deduplication is enabled.

Please keep ignoring Server::PartUUIDs here as well (like before) to preserve backward compatibility while the packet id remains reserved in Protocol.h.

@devcrafter devcrafter Mar 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To my understanding, we should never get this packet on client side

@devcrafter
devcrafter requested a review from azat March 16, 2026 22:11
@azat azat self-assigned this Mar 17, 2026

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

This is removal, not deprecation

Also let's add some reasons into description.

And do we want to keep other related parts (MOVE TO SHARD) for now and remove them later?

@devcrafter

devcrafter commented Mar 17, 2026 •

Copy link
Copy Markdown
Member Author

And do we want to keep other related parts (MOVE TO SHARD) for now and remove them later?

This change address only SELECT related part. AFAIU, MOVE TO SHARD functionality can be still useful, but I didn't estimate how good/bad it's.

Comment thread src/Core/Protocol.h Resolved
@devcrafter
devcrafter requested a review from azat March 24, 2026 20:55
Comment thread src/Server/TCPHandler.cpp Resolved
Comment thread src/Client/Connection.cpp Resolved
@devcrafter
devcrafter enabled auto-merge June 17, 2026 13:03
@clickhouse-gh

clickhouse-gh Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR removes the obsolete allow_experimental_query_deduplication feature: it deletes the part-UUID dedup plumbing (protocol packets, RemoteQueryExecutor retry path, and the UUID-filtered part selector) and turns the setting into a no-op. The setting defaulted to off, so the deleted code never ran for normal queries, and the single-node ClickBench scans/aggregations in Q4 and Q15 never exercise the distributed or part-selection paths that changed. The flagged -12% (Q4) and -14% (Q15) improvements therefore can't plausibly be caused by this change and read as run-to-run variance, especially with only 6 source runs and elevated measurement noise. Both have been downgraded to not-sure.

clickbench

⚠️ 2 inconclusive

Flagged queries (2 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 4 not_sure 267 235 -12.0% <0.0001 Pure removal of allow_experimental_query_deduplication; single-node scan path untouched. -12% reads as variance (6 runs)
⚠️ 15 not_sure 250 214 -14.4% <0.0001 Feature-removal PR doesn't touch the GROUP BY/scan hot path; -14% improvement is run-to-run variance, not the PR.

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 009337b7-5362-4554-9fd3-7ad2ff08dc87
  • MIRAI run: 04b802ed-5706-43cb-8342-3ab92612c9d3
  • PR check IDs:
    • clickbench_7025_1782084622
    • clickbench_7032_1782084622
    • clickbench_7042_1782084622
    • tpch_adapted_1_official_7054_1782084622
    • tpch_adapted_1_official_7061_1782084622
    • tpch_adapted_1_official_7072_1782084622

Comment thread src/Client/Connection.cpp
// materializing it (do not resize a vector to a peer-chosen size).
UInt64 num_part_uuids = 0;
readVarUInt(num_part_uuids, *in);
if (num_part_uuids > DEFAULT_MAX_STRING_SIZE)

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.

The obsolete payload is still capped by UUID count, not by bytes. DEFAULT_MAX_STRING_SIZE is 1_GiB, so a peer can send num_part_uuids = DEFAULT_MAX_STRING_SIZE and make this client drain 16 GiB through ignore before the packet is ignored and processing continues.

Since Server::PartUUIDs is no longer supported, please cap the byte payload instead, for example reject when num_part_uuids > DEFAULT_MAX_STRING_SIZE / sizeof(UUID), or fail closed without draining when preserving framing is not required.

@clickhouse-gh

clickhouse-gh Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 122/148 (82.43%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code

Full report · Diff report

@devcrafter
devcrafter added this pull request to the merge queue Jun 22, 2026
Merged via the queue into master with commit 795ce2b Jun 22, 2026
164 of 166 checks passed
@devcrafter
devcrafter deleted the remove-experimental-query-deduplication branch June 22, 2026 09:48
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 22, 2026
pull Bot pushed a commit to admariner/ClickHouse that referenced this pull request Sep 12, 2026
TCPHandler::receivePacketsExpectQuery() handles the packets that arrive
before any Query has been received. Its Data/Scalar case called
processUnexpectedData() and only then threw UNEXPECTED_PACKET_FROM_CLIENT.
That call builds a headerless NativeReader and reads a block, so the
column type name comes off the wire and is handed to DataTypeFactory.

Entering interserver mode requires only the name of a cluster that has a
non-empty <secret>, never the secret itself, and the secret is verified
only inside processQuery(), which this loop never reaches. So an
unauthenticated peer decided which type the server constructed and which
deserializer ran.

The read had no consumer for any peer either: its return value was
discarded, and the exception thrown right after is caught where
"if (!query_state) return;" exits runImpl, so the exception is never
sent, the connection is closed, and no further byte is read from the
socket. runImpl's exception handler already documents that policy ("the
server should not try to skip (parse, decompress) the remaining packets
sent by the client, as it will lead to additional work and unneeded
exposure to unauthenticated connections"); the parse it forbids had
already happened one frame earlier. The adjacent case of the same
switch, processObsoleteIgnoredPartUUIDs(), was given exactly this shape
in ClickHouse#99398.

No setting gates the rejection, deliberately. The TablesStatusRequest
path needed an operator opt-out when it was hardened in ClickHouse#99854 because
it was a served path, and rejecting it broke rolling upgrades (ClickHouse#113602).
Data before Query has always thrown, so there is no working flow to
preserve, and nothing a client can observe changes: the connection
closes with nothing written back, before and after.

The regression test completes an accepted interserver handshake over a
raw socket and then sends a Data packet declaring a column type that
does not exist. Without this change the server logs "Unknown data type
family: NoSuchTypeGroeneAI", which is the proof that a wire-supplied
type name reached DataTypeFactory before authentication. It is extended
into the existing pre-authentication interserver test module rather than
added as a new one, because that module already provides the cluster
with a <secret> and a handshake pinned below the chunked-packets
revision, which is what makes a hand-built packet feasible.

Requested by @ nikitamikhaylov, relayed via OranjeAI.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes 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.

4 participants