Repository navigation
Add setting for compatibility serialziation of string - #90880
Merged
Merged
Conversation
Contributor
|
Workflow [PR], commit [79dabb2] Summary: ❌
|
Avogar
approved these changes
Nov 26, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a compatibility issue in the in-memory serialization of String aggregation states that could lead to duplicate results when executing aggregation queries across a cluster with mixed ClickHouse versions. The fix introduces a new setting serialize_string_in_memory_with_zero_byte (defaulting to true) that controls whether String values are serialized with a trailing zero byte during aggregation. This ensures consistent serialization behavior across different server versions.
Key Changes:
- Added
serialize_string_in_memory_with_zero_bytesetting to control String serialization behavior during aggregation - Updated all serialization/deserialization methods across column types to accept and propagate
SerializationSettings - Modified String column serialization to conditionally append zero byte based on the new setting
Reviewed changes
Copilot reviewed 69 out of 70 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/test_string_aggregation_compatibility/test.py | Integration tests verifying compatibility between versions with/without the new setting |
| src/Core/Settings.cpp | Added serialize_string_in_memory_with_zero_byte setting definition |
| src/Core/SettingsChangesHistory.cpp | Registered the new setting in version 25.8 history |
| src/Columns/IColumn.h | Added SerializationSettings struct and updated all serialization method signatures |
| src/Columns/ColumnString.cpp | Core logic changes to conditionally serialize strings with zero byte terminator |
| src/Columns/ColumnUnique.h | Updated deserialization to handle zero byte when setting is enabled |
| src/Interpreters/Aggregator.h | Added serialize_string_with_zero_byte parameter to Aggregator::Params |
| src/Interpreters/Aggregator.cpp | Propagates serialization settings through aggregation methods |
| src/Common/ColumnsHashing.h | Extended HashMethodSerialized to use serialization settings |
| Multiple column types | Updated all column implementations to accept and forward SerializationSettings parameter |
Avogar
reviewed
Nov 27, 2025
This was referenced Dec 2, 2025
This was referenced Dec 2, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 2, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 2, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 2, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 2, 2025
antonio2368
added a commit
that referenced
this pull request
Dec 5, 2025
Backport #90880 to 25.8: Add setting for compatibility serialziation of string
antonio2368
pushed a commit
that referenced
this pull request
Dec 5, 2025
clickhouse-gh Bot
added a commit
that referenced
this pull request
Dec 5, 2025
Backport #90880 to 25.10: Add setting for compatibility serialziation of string
clickhouse-gh Bot
added a commit
that referenced
this pull request
Dec 5, 2025
Backport #90880 to 25.9: Add setting for compatibility serialziation of string
antonio2368
added a commit
that referenced
this pull request
Dec 5, 2025
Backport #90880 to 25.11: Add setting for compatibility serialziation of string
alexey-milovidov
added a commit
to amosbird/ClickHouse
that referenced
this pull request
May 9, 2026
…ision The test was added in ClickHouse#90880 to demonstrate a cross-version string serialization bug that only manifests when two-level aggregation is active across servers running incompatible serialization formats. This PR introduces `AggregationMethodPackedString` for the `key_string` slot, replacing `AggregationMethodString` (`StringHashTable`). Because the on-the-wire layout for single-string-key aggregation states is incompatible between the two methods, this PR raises `DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD` from 54448 to 54484. As a side effect, two-level aggregation is now disabled in distributed queries against any server older than 54484 (including 25.6, used by `node256` in the integration test), and the bug demonstrated by the test cannot be reproduced anymore — the deduplication succeeds and the query returns 10000 instead of 20000. Update the assertion to 10000 and add a comment explaining the change. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=93271&sha=6bde8cea7bc1e97b3d8cd5c96e902042f1c7fd60&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%205%2F6%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alexey-milovidov
added a commit
to amosbird/ClickHouse
that referenced
this pull request
May 19, 2026
…ision The test was added in ClickHouse#90880 to demonstrate a cross-version string serialization bug that only manifests when two-level aggregation is active across servers running incompatible serialization formats. This PR introduces `AggregationMethodPackedString` for the `key_string` slot, replacing `AggregationMethodString` (`StringHashTable`). Because the on-the-wire layout for single-string-key aggregation states is incompatible between the two methods, this PR raises `DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD` from 54448 to 54484. As a side effect, two-level aggregation is now disabled in distributed queries against any server older than 54484 (including 25.6, used by `node256` in the integration test), and the bug demonstrated by the test cannot be reproduced anymore — the deduplication succeeds and the query returns 10000 instead of 20000. Update the assertion to 10000 and add a comment explaining the change. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=93271&sha=6bde8cea7bc1e97b3d8cd5c96e902042f1c7fd60&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%205%2F6%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pull Bot
pushed a commit
to admariner/ClickHouse
that referenced
this pull request
Jul 26, 2026
…ision The test was added in ClickHouse#90880 to demonstrate a cross-version string serialization bug that only manifests when two-level aggregation is active across servers running incompatible serialization formats. This PR introduces `AggregationMethodPackedString` for the `key_string` slot, replacing `AggregationMethodString` (`StringHashTable`). Because the on-the-wire layout for single-string-key aggregation states is incompatible between the two methods, this PR raises `DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD` from 54448 to 54484. As a side effect, two-level aggregation is now disabled in distributed queries against any server older than 54484 (including 25.6, used by `node256` in the integration test), and the bug demonstrated by the test cannot be reproduced anymore — the deduplication succeeds and the query returns 10000 instead of 20000. Update the assertion to 10000 and add a comment explaining the change. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=93271&sha=6bde8cea7bc1e97b3d8cd5c96e902042f1c7fd60&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%205%2F6%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Aug 8, 2026
The previous commit wrote only `false`, on the argument that an absent name leaves the receiver at the declared default `true`. That is true of a receiver that declares the name, and wrong of the receivers the argument was meant to protect. `v25.8.12.129-lts` does not declare the setting, and its GROUP BY key path (`serializeKeysToPoolContiguous` -> `ColumnString::serializeValueIntoArena`) takes no serialization settings and writes no trailing zero byte - it behaves exactly like `serialize_string_in_memory_with_zero_byte = false`. Omitting `true` towards such a peer therefore does not leave it at `true`; it silently hands it the other key layout, which is the divergence this PR exists to close. `v25.8.13.73-lts` backported the setting (ClickHouse#90880) and does default it to `true`, yet both advertise query-plan serialization version 0, so `version` cannot tell the two apart and no gate can be built on it. So the assignment goes back to unconditional, and the test now requires the name on the wire for both values at version 0 as well as at the current version. Reverting either production line still fails exactly that step's round-trip test. Found by the second-model review, which caught the bad premise in the previous commit.
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…ision The test was added in ClickHouse#90880 to demonstrate a cross-version string serialization bug that only manifests when two-level aggregation is active across servers running incompatible serialization formats. This PR introduces `AggregationMethodPackedString` for the `key_string` slot, replacing `AggregationMethodString` (`StringHashTable`). Because the on-the-wire layout for single-string-key aggregation states is incompatible between the two methods, this PR raises `DBMS_MIN_REVISION_WITH_CURRENT_AGGREGATION_VARIANT_SELECTION_METHOD` from 54448 to 54484. As a side effect, two-level aggregation is now disabled in distributed queries against any server older than 54484 (including 25.6, used by `node256` in the integration test), and the bug demonstrated by the test cannot be reproduced anymore — the deduplication succeeds and the query returns 10000 instead of 20000. Update the assertion to 10000 and add a comment explaining the change. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=93271&sha=6bde8cea7bc1e97b3d8cd5c96e902042f1c7fd60&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%205%2F6%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix compatibility of in-memory serialization of String aggregation state. Different serialization could lead to duplicate results if aggregation query is executed on instances with different versions.
New serialization can be enabled with
serialize_string_in_memory_with_zero_byte.Documentation entry for user-facing changes