Skip to content

Remove the binary serialization format of settings - #131099

Merged
alexey-milovidov merged 8 commits into
masterfrom
remove-binary-settings-serialization
Nov 14, 2026
Merged

alexey-milovidov merged 8 commits into
masterfrom
remove-binary-settings-serialization

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Remove the binary serialization format of settings (SettingsWriteFormat::BINARY). Distributed async inserts (#129950) and the query plan (#129973) no longer use it. The only remaining user was the native protocol with peers older than revision 54429 (DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS, 2019).

  • SettingsWriteFormat is removed, and so is the format argument of Settings::write and Settings::read. Settings are always written as (name, flags, value-as-string).
  • A peer below revision 54429 can still exchange queries without settings, because an empty list (a single VarUInt 0) is the same in both formats. If such a client sends settings, the server throws NOT_IMPLEMENTED. The client refuses to send changed settings to such a server.
  • Per-field binary serialization stays only for the setting types used by BaseSettings::writeChangedBinary, which serializes object storage settings (S3AuthSettings, S3RequestSettings, DataLakeStorageSettings; the private repository still uses it). DataLakeStorageSettings include all format settings, so these types are numbers, Bool, Seconds, String, enums, Char, UInt64Auto, URI and Timezone. It is removed from the other types: MaxThreads, Map, TriBool, MultiEnum, Custom, ASTFunction and DataType. This includes SettingFieldMap, the only path from settings into the binary serialization of Field. Every setting in the lists of these three settings classes is checked at compile time with ASSERT_SETTING_SUPPORTS_BINARY_SERIALIZATION, so adding a setting of a type without binary serialization there fails the build. For other settings the ops are null, and the accessor throws a LOGICAL_ERROR that names the setting. A unit test covers the round trip of changed data lake settings of these types and reading a pinned binary layout.
  • writeFieldBinary/readFieldBinary themselves stay. They are the format of persisted data (statistics, Iceberg data object info, refresh task state) and of the serialized query plan.
  • The native protocol spec (docs/resources/develop-contribute/native-protocol/protocol.mdx) is updated.

Changelog category (leave one):

  • Backward Incompatible Change

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

Clients and servers with native protocol revision older than 54429 (ClickHouse releases from 2019 and older, or third-party drivers that announce such a revision) can no longer pass query settings in the old binary format. Queries without settings still work.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/131099]

Version info

  • Merged into: 26.11.1.2323-master (included in 26.11 and later)

After distributed async inserts and the query plan stopped using it, the only
user of `SettingsWriteFormat::BINARY` was the native protocol with peers older
than revision 54429 (`DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS`,
2019). Remove `SettingsWriteFormat` and the format argument of `Settings::write`
and `Settings::read`: settings are always written as strings with flags.

A peer below revision 54429 can still exchange queries without settings, because
an empty list (a single empty name) is the same in both formats. If such a client
sends settings, the server throws `NOT_IMPLEMENTED`; the client refuses to send
changed settings to such a server.

The per-field binary serialization is kept only for the setting types used by
`BaseSettings::writeChangedBinary` (object storage settings: numbers, `Bool`,
`Seconds`, `String`, enums). It is removed from the other types, including
`SettingFieldMap`, the only way from settings into the binary serialization
of `Field`. For those types `SettingFieldOps::write_binary`/`read_binary` are
null and the accessor throws a `LOGICAL_ERROR`.

The native protocol spec is updated accordingly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d9a817c]

Summary: ✅


AI Review

Summary

Reviewed #131099 at d9a817c8e8681013ddbce5d5c4db924c42f7e8ed, including all prior discussion. The change removes legacy binary query-setting serialization while preserving binary serialization for object-storage settings. The earlier DataLakeStorageSettings finding is fixed, with compile-time checks and regression tests added. No actionable findings remain. Assessment is based on source review and available CI results; tests were not run locally.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Nov 12, 2026
@mintlify

mintlify Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 14, 2026, 2:57 PM

@alexey-milovidov alexey-milovidov left a comment

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.

Amazing change! 🚀

@clickhouse-gh clickhouse-gh Bot added the comp-settings Settings & configuration infrastructure (server/user/query settings, profiles). label Nov 12, 2026
`05136_legacy_binary_settings_signed_integer` checked that a setting sent in the binary
format by a client below revision 54429 is applied. This format is no longer supported.
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131099&sha=291cb88d3c46170c41ed8cbfb070e61aaee428e1&name_0=PR&name_1=Fast%20test
#131099

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Core/BaseSettings.h Resolved
@clickhouse-gh

clickhouse-gh Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d9a817c8e with master 1b7851acb (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

70 object files changed (-54.79 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Core/SettingFieldDataType.cpp.o 37.64 KiB 8.66 KiB -28.99 KiB (-77.01%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.62, programs/clickhouse-keeper ×0.67 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 6.1 s 12.4 s +8.7 s (+232%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.5 s 7.4 s +5.2 s (+241%)
Compile time of recompiled translation units

1231 translation units recompiled, 8687 s compile time in total, 1231 of them have a recent master baseline.

Job report

alexey-milovidov and others added 2 commits November 13, 2026 00:29
`DataLakeStorageSettings` include all format settings, so `writeChangedBinary` also
serializes `Char`, `UInt64Auto` and `URI` settings (and `Timezone` in the private
repository). Restore `writeBinary` and `readBinary` for these types.

To catch this at compile time instead of with a `LOGICAL_ERROR` at runtime, every
setting in the lists of `DataLakeStorageSettings`, `S3AuthSettings` and
`S3RequestSettings` is now checked with `ASSERT_SETTING_SUPPORTS_BINARY_SERIALIZATION`.

Add a unit test of the round trip of changed data lake settings of these types and
of reading a pinned binary layout.

Review: #131099 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131099&sha=7e6496c276d06182f222890d631c274248763581&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20targeted%29 (05137_lazy_load_tables_replace_proxy_after_load: total_bytes_uncompressed is 0 instead of 1) and provide a fix in a separate PR. It is flaky on master as well (failed in master runs and several unrelated PRs on 2026-11-12 and 2026-11-13). If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

Acknowledged. The fix is in progress, no PR yet; I'll link it here when it opens.

Cause: #118699 replaces the proxy only when nobody else holds it (DatabaseCatalog::replaceUnusedTableInUUIDMapping returns early unless old_table.use_count() == 2). In the parallel jobs, a concurrent catalog-wide system.columns scan from another test holds every table's StoragePtr for its whole duration, so the lookups right after the load keep the proxy, and the proxy does not forward totalBytesUncompressed. The fix I'm preparing drops that one assertion from 05137, since 05616_lazy_load_tables_replace_proxy_held already checks the replacement with a wait.

@groeneai

Copy link
Copy Markdown
Collaborator

Fixing PR: #131220 . It removes the total_bytes_uncompressed assertion from 05137_lazy_load_tables_replace_proxy_after_load; the proxy replacement itself stays covered by 05616_lazy_load_tables_replace_proxy_held, which waits for the holders to go away.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 14, 2026
alexey-milovidov and others added 2 commits November 14, 2026 14:42
…rmat`

The merge queue run failed in `Clang-tidy (changed files)`: test
`SecondsOnTheWireRejectNegativeAndOverflowingValues` from #131269 passes
`SettingsWriteFormat::STRINGS_WITH_FLAGS` to `Settings::read`, which is the only format now.

https://github.com/ClickHouse/ClickHouse/actions/runs/43592425942/job/132440172906
Related: #131099

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 14, 2026
Merged via the queue into master with commit 95d2576 Nov 14, 2026
205 checks passed
@alexey-milovidov
alexey-milovidov deleted the remove-binary-settings-serialization branch November 14, 2026 23:07
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 14, 2026
alexey-milovidov added a commit to groeneai/ClickHouse that referenced this pull request Nov 15, 2026
`StorageSharedMergeTree::setTableStructure` in the private repository applies
replicated `ALTER` metadata with `setProperties(..., /*attach = */ true)` and
rebuilds `serialization_hints` later in a separate `lockParts` scope, the same
window this PR closes for `StorageReplicatedMergeTree`. It hit the
`new_hint->structureEquals(*info)` assertion in the stress test of the sync of
ClickHouse#131099. To switch it to the new
helper it must keep skipping the query-time checks, so the helper takes
`attach` like `setProperties` does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 15, 2026
…skip-invalid-values

Resolve the conflicts with ClickHouse#131099, which removed `SettingsWriteFormat`:
`BaseSettings::read` and `Settings::read` now take only `skip_invalid_values`,
and the tolerant parse applies to the single remaining string path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 22, 2026
Conflicts: `src/Client/Connection.cpp`, `src/Core/BaseSettings.h`,
`src/Core/Settings.cpp`, `src/Core/Settings.h`.

They come from #131099, which
removed `SettingsWriteFormat` on master and is not in 26.10. The resolution
keeps the `format` argument of `read` and adds `skip_invalid_values` after it,
so `Connection::receiveHello` calls
`settings.read(*in, SettingsWriteFormat::STRINGS_WITH_FLAGS, true)`.
The new `Settings.SkipInvalidValuesKeepsTheDefaultsAndReadsTheRest` test in
`gtest_settings.cpp` merged cleanly but is adapted to the same signature.

The resulting tree is identical to the resolution proposed in
#132962 (comment) (commit
`345c09ac114e` of `groeneai/ClickHouse`).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
alexey-milovidov pushed a commit that referenced this pull request Nov 22, 2026
Resolve the conflicts of the cherry-pick of #131636. 26.9 still has
`SettingsWriteFormat` (master removed it in #131099), so `read` keeps its
`format` argument and takes `skip_invalid_values` after it, as in the
first commit of #131636 (669fb8d), which was written against this API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov pushed a commit that referenced this pull request Nov 22, 2026
Resolve the conflicts of the cherry-pick of #131636. 26.8 still has
`SettingsWriteFormat` (master removed it in #131099), so `read` keeps its
`format` argument and takes `skip_invalid_values` after it, as in the
first commit of #131636 (669fb8d), which was written against this API.

The new gtest goes right after `SecondsOnTheWireRejectNegativeAndOverflowingValues`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

1 active deployment
staging - docs — d9a817c8 Deployed Nov 14, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-settings Settings & configuration infrastructure (server/user/query settings, profiles). 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