Skip to content

Revert "Revert "Enable the bucketed schema of system.metric_log by default"" - #124016

Merged
alexey-milovidov merged 9 commits into
masterfrom
revert-124011-revert-118318-bucketed-metric-log-default
Oct 9, 2026
Merged

alexey-milovidov merged 9 commits into
masterfrom
revert-124011-revert-118318-bucketed-metric-log-default

Conversation

@Algunenano

@Algunenano Algunenano commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Reverts #124011

See #118318 (comment)


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

Version info

  • Merged into: 26.10.1.1895-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4163234]

Summary: ✅


AI Review

Summary

This PR restores the bucketed schema as the implicit default for system.metric_log and carries that change through the main compatibility surfaces it affects: old-planner COLUMNS / qualified *, system.all_metric_log over rotated wide tables, documentation output, and large SHOW CREATE consumers in CI log replication. I re-read the current diff, every prior review thread and reply, and the latest all-green CI report for https://github.com/ClickHouse/ClickHouse/pull/124016, and I did not find any remaining correctness or compatibility issues in the current head.

Final Verdict

✅ Approved.

LLVM Coverage Report

Measured on commit 4163234.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.20% 92.10% -0.10%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 142/149 (95.30%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 5, 2026
Comment thread src/Interpreters/SystemLog.cpp Resolved
Comment thread src/Interpreters/BucketedMetricLog.h Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-system-table system.* tables (introspection, system metadata, performance visibility). label Oct 5, 2026
@Algunenano
Algunenano marked this pull request as ready for review October 5, 2026 13:15
alexey-milovidov and others added 2 commits October 6, 2026 06:44
…ve `MergeTree` defaults

Do not warn about a setting of the bucketed `Map` serialization that is not
spelled in an explicit `engine` of `metric_log` when its effective
`MergeTree` default already has the required value. Clarify in the
documentation of `BucketedMetricLog` that an explicit `engine` keeps `wide`
as the default only when `schema_type` is not set.

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

clickhouse-gh Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 41632346b with master 14e7d929d (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of a98bfcfa3; 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

31 object files changed (+68.17 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Interpreters/SystemLog.cpp.o 4.91 MiB 4.96 MiB +47.68 KiB (+0.95%)

719 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.

Compile time of recompiled translation units

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

Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost -738.9 s (-9%) in total before that adjustment.

Job report

Address review: the test now runs the matcher explicitly with
`enable_analyzer = 0` and `enable_analyzer = 1`.

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

Copy link
Copy Markdown
Member

🕵 On 35bc2c4, Stateless tests (arm_asan_ubsan, azure, sequential) hit the job's 9000-second timeout after 1166 of 1167 tests had passed: https://s3.amazonaws.com/clickhouse-test-reports/PRs/124016/35bc2c4d560f102fc44083b0d69d2a68790f9cde/pr/stateless_tests_arm_asan_ubsan_azure_sequential/job.log. I think this is unrelated to the PR. On master the same job already spends about 8500 seconds in tests, so it sits right at the limit. #123849 splits the job into two batches to fix that. CI is re-running on d1e72cc.

… a qualified asterisk with the old planner

`SELECT t.* ... SETTINGS asterisk_include_alias_columns = 1, enable_analyzer = 0` dropped
the alias columns (such as the per-metric aliases of the `bucketed` schema of
`system.metric_log`), while unqualified `*` and the analyzer kept them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Interpreters/SystemLog.cpp Resolved
…ugh `system.all_metric_log`

The union table pinned the columns of the `bucketed` schema, where every metric is
`ALIAS metrics['...']`. An `ALIAS` in a `Merge` table is expanded before reading, so for the
rotated `metric_log_0` of the `wide` schema, which has no `metrics` column, the union table
returned default values instead of the stored metrics. Declare these columns as ordinary ones in
the union table, so that each underlying table provides them on its own: physically for `wide`,
as its `ALIAS` for `bucketed`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Interpreters/SystemLog.cpp Resolved
alexey-milovidov and others added 3 commits October 8, 2026 11:59
… asterisk

The previous commit declared the per-metric columns of the union table as ordinary columns, so
`SELECT * FROM system.all_metric_log` started to compute about a thousand `metrics['...']` aliases
of the underlying `bucketed` table for every row, and the query in `01161_all_system_tables`
timed out after 300 seconds. Declare them as `MATERIALIZED`: they are still read by name from
every underlying table, physically for `wide` and as its `ALIAS` for `bucketed`, but, like the
`ALIAS` columns of `system.metric_log`, they are not expanded by an asterisk.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124016&sha=latest&name_0=PR&name_1=Stateless%20tests%20(arm_binary%2C%20sequential)
#124016

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l_parts` of an explicit engine

The setting only controls how zero-level parts are written before merges, not the bucket layout
of merged parts, so an explicit `bucketed` engine that changes it to `with_buckets` should not get
the warning that `metrics` will not be stored in 128 constant buckets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 9, 2026
Merged via the queue into master with commit a5dff1d Oct 9, 2026
153 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-124011-revert-118318-bucketed-metric-log-default branch October 9, 2026 02:49
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 9, 2026
diegomestre2 pushed a commit to diegomestre2/ClickHouse that referenced this pull request Oct 15, 2026
Copying a `ColumnDefault` deep-clones its expression AST, and copying a
`ColumnDescription` also clones its codec and TTL ASTs. With the bucketed
`system.metric_log` schema (the default since ClickHouse#124016) the table has ~2200
`ALIAS` columns, and every metadata copy clones and later destroys all of
their ASTs. A `system.dashboards` query copies that metadata many times:
in debug and sanitizer builds `MergeTreeData::getInMemoryMetadataPtr`
returns a fresh copy on every call (to catch lifetime bugs), and
`StorageMerge::getInMemoryMetadataPtr` / `StorageMaterializedView::getInMemoryMetadataPtr`
copy it on every call through `withVirtuals`. Under ASan the clones were 39%
of the CPU of the test's queries, and `03540_system_dashboards` doubled its
runtime on every debug and sanitizer lane and hit the 600 s timeout on
amd_tsan with s3 storage.

Add `StorageInMemoryMetadata::copySharingColumnASTs` (backed by
`ColumnsDescription::copySharingASTs`, a tagged `ColumnDescription`
constructor and `ColumnDefault::copySharingExpression`): the copy has its own
metadata, columns description and column descriptions, and shares only the
immutable ASTs. Use it at the three read-only per-call sites. It never goes
through `ColumnsDescription::add`, whose function name normalizer modifies
the AST in place. The copy constructor and assignment still deep-copy, so
every mutable copy (ALTER, CREATE AS, ...) keeps owning its ASTs. In debug
builds the lifetime check still returns a distinct metadata object per call;
only a dangling reference into a column AST is no longer caught by it.

Also add an rvalue `IStorage::setInMemoryMetadata` overload and move the
local metadata in the `Merge`, `Distributed` and `Dummy` constructors. The
`Distributed` constructor reads the columns for the sharding key after
setting the metadata, so it now reads them from its `columns_` argument,
which is what the metadata was built from.

Measured on the test's 498 dashboard queries in `clickhouse local` (debug
build): bucketed schema 25.2 s -> 20.6 s, wide schema unchanged.

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

Labels

comp-system-table system.* tables (introspection, system metadata, performance visibility). 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants