Skip to content

Mark the ZXC codec as experimental - #111007

Merged
alexey-milovidov merged 8 commits into
masterfrom
zxc-codec-experimental
Jul 22, 2026
Merged

alexey-milovidov merged 8 commits into
masterfrom
zxc-codec-experimental

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

The ZXC codec was added in #110620 but, unlike the other recently added codecs (ALP, SZ3), it was not placed in the experimental category. This follow-up marks it experimental so that using it requires SET allow_experimental_codecs = 1, matching the convention for new codecs that are not yet meant for production use.

  • CompressionCodecZXC::isExperimental now returns true, so the codec is rejected with BAD_ARGUMENTS unless allow_experimental_codecs is enabled, and system.compression_codecs reports it as experimental.
  • Test 04545_zxc_codec enables the setting and adds a negative case asserting the codec is rejected without it.
  • Documentation gets an experimental badge and a note, consistent with ALP and SZ3.

During review it turned out the codec-valued MergeTree settings (marks_compression_codec, primary_key_compression_codec, default_compression_codec) bypassed the experimental-codec gate entirely, so this PR also closes those holes:

  • CREATE TABLE ... SETTINGS default_compression_codec = 'ZXC' (and the other two settings) is validated against allow_experimental_codecs, including full-definition ATTACH TABLE t UUID '...' (...), via the new CompressionCodecFactory::validateCodecString.
  • ALTER TABLE ... MODIFY SETTING and ALTER TABLE ... RESET SETTING are validated in MergeTreeData::checkAlterIsPossible on the initiator with the query context (RESET against the post-reset value from the current <merge_tree> config defaults).
  • Values inherited from the current <merge_tree> config defaults are validated even when loading a table (server restart, short ATTACH), because a table that stores no codec settings falls back to them; values stored in the table's own SETTINGS clause were gated when introduced and remain loadable. At startup the check runs against the default profile, which is where an operator can legitimately opt in to such a config default.
  • Tests: 04616_experimental_codec_in_merge_tree_settings, 04617_experimental_codec_attach_full_definition, and integration test test_experimental_codec_config_default (config default + CREATE/ATTACH/RESET SETTING/restart).

ZXC has not appeared in a stable release yet (it was merged into master in #110620), so this change simply adjusts the gating of the unreleased feature before it ships; the codec's changelog entry from #110620 already covers it.

Related: #110620

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Backported to: 26.7.2.1

The `ZXC` codec was added in #110620 but, unlike the other recently added
codecs (`ALP`, `SZ3`), it was not placed in the experimental category. Mark
it experimental so that using it requires `SET allow_experimental_codecs = 1`,
matching the convention for new codecs that are not yet meant for production.

- `CompressionCodecZXC::isExperimental` now returns `true`, so the codec is
  rejected with `BAD_ARGUMENTS` unless `allow_experimental_codecs` is enabled,
  and `system.compression_codecs` reports it as experimental.
- Test `04545_zxc_codec` enables the setting and adds a negative case that the
  codec is rejected without it.
- Documentation gets an experimental badge and note.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mintlify

mintlify Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 19, 2026, 5:32 PM

@clickhouse-gh

clickhouse-gh Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4ec42a3]

Summary: ✅


AI Review

Summary

This PR marks ZXC as experimental, propagates the allow_experimental_codecs gate to the codec-valued MergeTree settings on CREATE, full-definition ATTACH, ALTER TABLE ... MODIFY SETTING, and ALTER TABLE ... RESET SETTING, and re-validates inherited <merge_tree> defaults on load while exempting codec values already stored in table metadata. I re-checked the prior review threads against the current code and tests; the remaining config-default / RESET SETTING bypass is closed, and I did not find a new unresolved correctness, compatibility, or evidence gap in the current patch.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 19, 2026
alexey-milovidov and others added 2 commits July 19, 2026 23:28
…t spec for experimental ZXC

Marking `ZXC` experimental flips its `system.codecs` row from
`is_experimental = 0` to `1` (via `CompressionCodecFactory::fillCodecDescriptions`
reading `isExperimental` directly), so update the checked-in reference in
`01222_system_codecs.reference`.

Also add the `allow_experimental_codecs` gate note for `0x9f` (`ZXC`) to the
Native format specification `NativeFormat.md`, consistent with `SZ3` and
`Quantized`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Compression/CompressionCodecZXC.h Resolved
…MergeTree settings

The settings `marks_compression_codec`, `primary_key_compression_codec` and
`default_compression_codec` were validated with plain `CompressionCodecFactory::get`,
which never checks `isExperimental`, so `CREATE TABLE ... SETTINGS
default_compression_codec = 'ZXC'` (and the corresponding `ALTER TABLE ... MODIFY
SETTING`) accepted an experimental codec with `allow_experimental_codecs = 0`.

Add `CompressionCodecFactory::validateCodecString` (validates a full codec expression
string without a column type through `validateCodecAndGetPreprocessedAST`) and enforce
the gate at the two user-facing entry points: CREATE in `registerStorageMergeTree`
(skipped for `ATTACH`/`SECONDARY_CREATE`/load, so existing tables remain loadable,
mirroring the column-codec gate) and `ALTER TABLE ... MODIFY SETTING` in
`MergeTreeData::checkAlterIsPossible` (initiator-side, with the query context; the
metadata-apply path on replicas is not re-checked).

Add a stateless regression test covering both entry points, the multi-codec case, and
that a table created with the codec stays loadable across `DETACH`/`ATTACH` without
the session setting.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The AST fuzzer (arm_asan_ubsan) failure is unrelated to this PR: it is a pre-existing UBSan float-to-integer overflow in CREATE QUOTA max value parsing (ParserCreateQuotaQuery.cpp:166). Fix: #111032

…l-definition ATTACH too

A full-definition `ATTACH TABLE t UUID '...' (...) ENGINE = MergeTree ... SETTINGS default_compression_codec = 'ZXC'`
is CREATE-like user input but runs under `LoadingStrictnessLevel::ATTACH`, so the previous
`args.mode <= LoadingStrictnessLevel::CREATE` condition let it bypass `allow_experimental_codecs`.
Now the gate also applies when `args.mode == LoadingStrictnessLevel::ATTACH` and the definition is
fresh user input (`!attach_short_syntax`). Definitions read back from stored metadata (short
`ATTACH TABLE t`, `ATTACH DATABASE`, server restart) are marked with `attach_short_syntax` by
`createTableFromAST` and remain loadable, as does `SECONDARY_CREATE` (`Replicated` DDL replay, `RESTORE`).

Co-Authored-By: Claude Fable 5 <[email protected]>
@rschu1ze rschu1ze self-assigned this Jul 20, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Stateless tests (amd_llvm_coverage, ...) failure ("Server died") is unrelated to this PR: the server aborted on the pre-existing logical error "Arguments of 'multiply' have incorrect data types" — a race between EXCHANGE TABLES and SELECT in 03915_exchange_tables_race, tracked in #110133. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111007&sha=8d1cb2c6e74a8edbfcf0a30ae9ed8e60fa491db3&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20old%20analyzer%2C%20s3%20storage%2C%20DBReplicated%2C%20WasmEdge%2C%20parallel%2C%202%2F3%29

@groeneai, investigate the failure and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

Confirmed: same signature as #110133 (multiply Int256 vs Float64 during partial-result header evaluation after a concurrent EXCHANGE TABLES).

Fix already in progress: #109747 (OPEN, awaiting review). It adds an argument-type check in ActionsDAG::executeActionForPartialResult so the mismatch raises a recoverable TYPE_MISMATCH instead of aborting the server in debug/sanitizer/coverage builds. That prevents the abort; it does not remove the underlying EXCHANGE TABLES vs SELECT read-consistency race.

The gate on codec-valued MergeTree settings (`marks_compression_codec`,
`primary_key_compression_codec`, `default_compression_codec`) was keyed
to operation type, so values inherited from the current `<merge_tree>`
config defaults could still introduce an experimental codec (e.g. `ZXC`)
into existing tables without `allow_experimental_codecs`:

- On load (server restart, short `ATTACH`), the check was skipped
  entirely, although a table that stores no codec settings falls back to
  the current config defaults.
- `ALTER TABLE ... RESET SETTING` was not inspected by
  `MergeTreeData::checkAlterIsPossible` (only `MODIFY_SETTING` was),
  while `changeSettings` rebuilds the value from `getDefaultSettings`.

Key the load-path exemption to "value stored in the table's own
`SETTINGS` clause" instead: stored values were gated when introduced and
remain loadable, while values inherited from current config defaults are
validated even on load (at startup against the default profile, which is
where an operator can legitimately opt in to such a config default).
`FORCE_RESTORE` keeps skipping all sanity checks. Also gate
`RESET SETTING` against the post-reset default value.

Add an integration test covering CREATE/ATTACH/RESET with a `ZXC`
config default, the stored-metadata exemption, and a restart.
@alexey-milovidov

alexey-milovidov commented Jul 21, 2026 •

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111007&sha=472b806e1820703eafeb6fb2dcd4e928bb482baf&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

test_replicated_users/test.py::test_grant_revoke_replicated[With_ignored_on_cluster] (empty SHOW GRANTS right after a replicated GRANT) and test_replicated_users/test.py::test_rename_replicated[USER] (ACCESS_ENTITY_ALREADY_EXISTS in ZooKeeperReplicator::updateZooKeeper on ALTER USER ... RENAME) both look like replication races in ReplicatedAccessStorage/ZooKeeperReplicator, unrelated to this PR (compression codec gating). CI history shows the same tests failing ~70 times on 2026-07-14/15 in PR #106525 (which added a regression test around a ReplicatedAccessStorage race and has since been merged), and there is no tracking issue yet. Both were retry_ok in this run.

The other red, test_replicated_database/test.py::test_replicated_table_structure_alter, is known flaky: #110036.

@groeneai

Copy link
Copy Markdown
Collaborator

Acknowledged. Confirmed both are replication races in ReplicatedAccessStorage / ZooKeeperReplicator: empty SHOW GRANTS right after a replicated GRANT, and ACCESS_ENTITY_ALREADY_EXISTS in ZooKeeperReplicator::updateZooKeeper on ALTER USER ... RENAME. These are distinct from the earlier UNKNOWN_ROLE cache-eviction race (#106521), which was fixed by #107097 (merged) with the regression test added in #106525.

No fix is currently in progress for these two symptoms and there is no tracking issue yet. CIDB shows them PR-only over the last 30 days (0 on master), concentrated in the #106525 test-tuning runs plus this one amd_tsan hit. Investigating now; I will follow up here with a separate fix PR (or my findings).

@groeneai

Copy link
Copy Markdown
Collaborator

Fix PR: #111239

Both failures are one test bug in test_replicated_users, not a ReplicatedAccessStorage/ZooKeeperReplicator race:

  • test_grant_revoke_replicated[With_ignored_on_cluster] reads the grant back from node2 at test.py:167 with a bare, un-retried node2.query("SHOW GRANTS FOR theuser2") — the only cross-replica read in the file without a retry. The grant replicates to node2 asynchronously, so a fast read observes stale state. In the failing run node2 was read 265 ms after the node1 grant (06:26:15.015 -> 06:26:15.280) and returned empty.
  • test_rename_replicated[USER] is a cascade of that: when line 167 fails, the test aborts before DROP USER theuser2, leaking theuser2; the next test's ALTER USER theuser RENAME TO theuser2 then correctly hits the leftover entity (ACCESS_ENTITY_ALREADY_EXISTS — all 20 query_with_retry attempts fail identically, so it is a real collision, not a race). CI history confirms the two fail together in the same commit, never independently.

The server side is behaving correctly (the rename collision check and eventual-consistency propagation are both by design), so the fix is test-only: read the grant back with assert_eq_with_retry, and drop theuser2 / restore the profile in a finally block so nothing leaks into later tests. The two tests plus siblings pass in the integration harness (7 passed, no retries).

@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.20% 86.20% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 78.30% 78.30% +0.00%

Changed lines: Changed C/C++ lines covered: 44/45 (97.78%) · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Shall be merged before 26.7.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 22, 2026
Merged via the queue into master with commit 8c96ae7 Jul 22, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the zxc-codec-experimental branch July 22, 2026 20:29
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 22, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 22, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 22, 2026
clickhouse-gh Bot added a commit that referenced this pull request Jul 22, 2026
Backport #111007 to 26.7: Mark the ZXC codec as experimental
metadata.settings_changes = args.storage_def->settings->ptr();
}

/// The codec-valued MergeTree settings accept an arbitrary codec expression and are applied without

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.

@groeneai This is the wrong place for such checks. Please move it into MergeTreeSettingsImpl::sanityCheck (file: src/Storages/MergeTree/MergeTreeSettings.cpp).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Acknowledged. I will move the experimental-codec gate out of registerStorageMergeTree.cpp into MergeTreeSettingsImpl::sanityCheck (src/Storages/MergeTree/MergeTreeSettings.cpp) in a separate PR, since this one is already merged, and follow up here with the link.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Done in #111700: the CREATE-time check now lives in MergeTreeSettingsImpl::sanityCheck, next to the existing lossy-codec validation of the same three settings. The metadata-load paths that don't run sanityCheck (short/full ATTACH, SECONDARY_CREATE, config-default-on-load) keep a minimal counterpart in registerStorageMergeTree, now placed after the syntax branches so it covers both extended and deprecated syntax.

pull Bot pushed a commit to peijunlin2008/ClickHouse that referenced this pull request Aug 8, 2026
test_grant_revoke_replicated read the grant back from node2 with a bare,
un-retried query (the only cross-replica read in the file without a retry).
ReplicatedAccessStorage replicates the grant to node2 asynchronously, so a
fast read can observe stale state and return empty grants.

When that assert failed, the test aborted before dropping theuser2, leaking
the user into the next test, whose ALTER USER ... RENAME TO theuser2 then hit
the leftover entity with ACCESS_ENTITY_ALREADY_EXISTS. So both amd_tsan
failures reported on ClickHouse#111007 stem from this one test bug, not a server bug.

Read the grant back with assert_eq_with_retry, and drop theuser2 / restore the
profile in a finally block so nothing can leak into later tests.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Aug 14, 2026
The AST fuzzer with UBSan found that `CREATE QUOTA ... MAX execution_time = <huge number>`
casts an out-of-range double to `QuotaValue` (UInt64) in `parseMaxValue`
(`src/Parsers/Access/ParserCreateQuotaQuery.cpp:166`): the value is multiplied by the
quota type's output denominator (`execution_time` is stored in nanoseconds) without a
range check, which is undefined behavior:

    runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'

Bound the scaled value to the UInt64 range before the cast and throw a `BAD_ARGUMENTS`
exception for out-of-range, negative, or non-finite values, mirroring the existing
guard for the quota interval duration. Apply the same guard to
`QuotaTypeInfo::stringToValue`, which had the identical unchecked cast (reachable from
quotas defined in the users configuration).

Found by the AST fuzzer in an unrelated PR:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111007&sha=edff5021176b8081847ac3b4c6672f4089ad1ead&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan_ubsan%29
Related PR: #111007

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…mental

Mark the ZXC codec as experimental
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo v26.7-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants