Skip to content

Propagate data types serialization versions to nested data types - #94859

Merged
Avogar merged 35 commits into
ClickHouse:masterfrom
Avogar:propagate-type-serializations-2
Mar 10, 2026
Merged

Avogar merged 35 commits into
ClickHouse:masterfrom
Avogar:propagate-type-serializations-2

Conversation

@Avogar

@Avogar Avogar commented Jan 22, 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):

Propagate data types serialization versions to nested data types. For example, String serialization version with_size_stream previously was applied only on top-level String columns and Tuple elements. Now it's applied to any String type inside any nested type like Array/Map/Variant/JSON/etc. This behaviour is controlled by MergeTree setting propagate_types_serialization_versions_to_nested_types that is now enabled by default. After this change, newly created data parts cannot be read by older versions, but old parts can be read on new version with no problems. It means that upgrade is safe, but downgrade is not.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Note

High Risk
Changes MergeTree on-disk serialization behavior (and defaults) so new parts may be unreadable by older ClickHouse versions, with broad impact across many core data types and subcolumn paths (Array/Map/Nullable/JSON/Dynamic/Variant).

Overview
Propagates type-level serialization versions into nested types by default. Adds MergeTree setting propagate_types_serialization_versions_to_nested_types (enabled by default, tracked in SettingsChangesHistory) and persists/reads it in MergeTree serialization.json (only written when enabled).

Refactors core data type serialization selection. Replaces doGetDefaultSerialization() with doGetSerialization(const SerializationInfoSettings &) across many DataType* implementations, updates IDataType to build/wrap serializations from settings, and adjusts String/Variant/Dynamic/Object(JSON) serializations and subcolumn extraction to reuse the correct nested serializations (including new removeNamedSerialization() and passing dynamic/typed-path serializations through Object/JSON/shared-data paths).

Updates MergeTree writers/merge/mutation paths to pass the new setting into SerializationInfoSettings, and adjusts/adds tests to reflect new substream layouts and file-open counts (including a new test covering with_size_stream behavior inside nested types).

Written by Cursor Bugbot for commit 2403b5b. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.3.1.547

@clickhouse-gh

clickhouse-gh Bot commented Jan 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2403b5b]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Jan 22, 2026
@alexbakharew alexbakharew self-assigned this Feb 17, 2026

@alexbakharew alexbakharew left a comment

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.

Hi @Avogar
Just for clarifying: Are you sure that we want to break backward compatibility here? Was it requested by someone or it is just a part of improvements for serialization?

Comment thread src/DataTypes/DataTypeNullable.cpp Resolved
@Avogar

Avogar commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

Are you sure that we want to break backward compatibility here?

It's not actually backward-incomatible. It's forward-incompatible. Upgrades are safe, old parts will be read with no problems, but downgrades are not safe (unless new setting is disabled before upgrade or ccompatibility setting is used as we do in our cloud). So it's actually an improvement, but we don't have separate changelog category for such forward-incompatible changes and usually use Backward Incompatible Change category to highlight it in the changelog so users are careful during upgrade.

Was it requested by someone or it is just a part of improvements for serialization?

It's continuation of this performance improvement: #82850. That PR was incomplete and didn't propagate the new String serialization to nested data types.

@alexey-milovidov

Copy link
Copy Markdown
Member

Please merge with master to fix Kafka.

@Avogar
Avogar requested a review from alexbakharew February 23, 2026 18:24
Comment thread src/DataTypes/IDataType.cpp Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread src/DataTypes/DataTypeObject.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.80% 83.80% +0.00%
Functions 23.90% 23.90% +0.00%
Branches 76.30% 76.30% +0.00%

PR changed lines: PR changed-lines coverage: 93.92% (556/592)
Diff coverage report
Uncovered code

@Avogar
Avogar added this pull request to the merge queue Mar 10, 2026
Merged via the queue into ClickHouse:master with commit 7e4e20a Mar 10, 2026
159 checks passed
@Avogar
Avogar deleted the propagate-type-serializations-2 branch March 10, 2026 12:16
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 10, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@Avogar Can you tell from which versions the downgrade is incompatible? v25.12 could be safe since it introduced the size_stream serialization?

@Avogar

Avogar commented Mar 16, 2026

Copy link
Copy Markdown
Member Author

Downgrade to any version that doesn't contain this PR is incompatible (unless this setting was disabled before upgrade, for example using compatibility setting).

v25.12 could be safe since it introduced the size_stream serialization?

No, it won't be safe, because in 25.12 we didn't propagate size_stream serialization to all nested String subcolumns, so 25.12 won't be able to read new parts created with enabled new setting.

github-merge-queue Bot pushed a commit that referenced this pull request Apr 8, 2026
… change in 26.3 changelog

The entry about `propagate_types_serialization_versions_to_nested_types` (#94859) can cause
data loss on downgrade. Moved it to the top of the Backward Incompatible Change section and
added bold warnings to make this critical information more visible.

See #101429
See #94859 (comment)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@larry-cdn77

Copy link
Copy Markdown
Contributor

Is downgrade the same scenario as rolling upgrade here? By that I mean another node running old version reading parts fetched from a new version.

@Avogar

Avogar commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

If during rolling upgrade a new version created a new part with enabled setting, then old version won't be able to read data from this part until it's also upgraded.

For safe rolling upgrades, use compatibility setting, it keeps values of the changed settings consistent with the specified version.

@larry-cdn77

Copy link
Copy Markdown
Contributor

Thank you, this wasn't clear to me from the changelog message; now it is!

alexey-milovidov added a commit to groeneai/ClickHouse that referenced this pull request Aug 14, 2026
…tefunction-version-race

`master` has since landed the same fix through ClickHouse#94859 and ClickHouse#112052:
`setVersionToAggregateFunctions` now replaces every versioned nested type
instead of writing the shared type's `mutable version` field, and it carries
custom names (`Nested`, `SimpleAggregateFunction`) over the rebuild.

The conflicting parts of this branch are therefore resolved in favour of
`master`: its `replaceNestedSimpleTypes` walk supersedes the per-type
`doTransformChildren` machinery this branch added, and its handling of
`Variant` (descend, keep the discriminator order, fail when two alternatives
would collapse) and of `Dynamic` / `JSON` (states keep the version spelled in
their own type name) are deliberate decisions taken in review there.

What is left of this branch is what `master` does not have yet, and it keeps
the branch's intent: the race cannot come back, because the version can no
longer be assigned in place at all.
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.

6 participants