Skip to content

Add embedded documentation for table engines - #106177

Merged
alexey-milovidov merged 17 commits into
masterfrom
storage-engine-documentation
Jun 14, 2026
Merged

alexey-milovidov merged 17 commits into
masterfrom
storage-engine-documentation

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 31, 2026 •

Copy link
Copy Markdown
Member

Many parts of the ClickHouse codebase carry embedded documentation that is introspectable at runtime and used to generate the website documentation: scalar functions, aggregate functions, table functions, and settings all do. Table engines did not.

This PR adds embedded documentation for table engines. It is the first in a planned series that will do the same for database engines, data types, input/output formats, dictionary layouts, dictionary sources, and so on.

What it does:

  • Introduces a shared Documentation struct (src/Common/Documentation.h) for uniform system components. It plays the same role for table engines that FunctionDocumentation plays for functions, but without the function-specific fields (arguments, parameters, returned value, category).
  • Attaches a Documentation to every table engine via StorageFactory::registerStorage.
  • system.table_engines now exposes description, syntax, examples, introduced_in, and related columns.
  • For every engine that has a dedicated documentation page under docs/en/engines/table-engines/, the complete Markdown body of that page is embedded verbatim into the description field, so that the standalone Markdown files can later be dropped and regenerated from the embedded documentation. Engines without a dedicated page (e.g. the Replicated* variants, Loop, WindowView, MaterializedView, and the backend-specific object storage variants such as IcebergS3) keep a concise description for now.

Implementation note: the MergeTree documentation exceeds the 65536-byte string literal length that C++ compilers are required to support, so its description is concatenated at runtime from several smaller string literals.

Follow-up (not in this PR): a generator that writes the Markdown pages from the embedded documentation, after which the standalone .md files can be removed.

Changelog category (leave one):

  • Improvement

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

Table engines now carry embedded documentation, introspectable via the new description, syntax, examples, introduced_in, and related columns of the system.table_engines table.

Documentation entry for user-facing changes

  • Documentation is provided as part of this change (embedded documentation in system.table_engines and an updated system.table_engines system-table page).

Version info

  • Merged into: 26.6.1.788

Introduce a shared `Documentation` struct (`src/Common/Documentation.h`) for
uniform system components. It plays the same role for table engines that
`FunctionDocumentation` plays for functions, but without the function-specific
fields (arguments, parameters, returned value, category).

The struct is attached to table engines via `StorageFactory::registerStorage`,
and `system.table_engines` now exposes `description`, `syntax`, `examples`,
`introduced_in`, and `related` columns.

For every engine that has a dedicated documentation page under
`docs/en/engines/table-engines/`, the complete Markdown body of that page is
embedded verbatim into the `description` field, so that the standalone Markdown
files can later be dropped and regenerated from the embedded documentation.
Engines without a dedicated page (e.g. the `Replicated*` variants, `Loop`,
`WindowView`, `MaterializedView`, and the backend-specific object storage
variants such as `IcebergS3`) keep a concise description.

The `MergeTree` documentation exceeds the 65536-byte string literal length that
C++ compilers are required to support, so its `description` is concatenated at
runtime from several smaller string literals.

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

clickhouse-gh Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [836aaed]

Summary: ✅


AI Review

Summary

This PR adds embedded Documentation metadata for table engines and exposes it through new trailing columns in system.table_engines. I rechecked the current head against all prior inline threads, compared the embedded Markdown bodies with the corresponding standalone table-engine pages, and reviewed the StorageFactory / system.table_engines plumbing. I did not find any remaining correctness, compatibility, or documentation-contract findings that need inline comments.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 31, 2026
Comment thread src/Storages/StorageView.cpp Resolved
alexey-milovidov and others added 2 commits June 1, 2026 06:00
The embedded documentation added to the table-engine registration files is
verbatim Markdown, which tripped the C++ style checks:

- The "style error on this line" check flagged Markdown content indented by
  1-3 spaces (SQL/XML examples inside code fences), read as "indentation not a
  multiple of 4". Such lines are left-aligned; this is a no-op for Markdown
  body text and only de-indents fenced examples.
- Trailing whitespace and double-spaces after a comma are removed.
- The whitespace-before-comma in the `StorageExecutable` Python example is
  fixed (`letters ,k=10` -> `letters, k=10`).
- ClickHouse pretty-print output blocks had their row-number prefixes (`N. `)
  and border indentation realigned so the boxes line up at column 0.
- The `Sql` abbreviation check is taught to ignore the canonical Apache Arrow
  `FlightSql.html` documentation URL referenced in `StorageArrowFlight`.

#106177

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`StorageFactory::get` rejects direct `ENGINE = ...` creation of `View`,
`Loop`, `MaterializedView`, and `WindowView`, so the `syntax` advertised in
`system.table_engines` for these would throw if copied verbatim. Replace it
with the real user-facing forms:

- `View` -> `CREATE VIEW name AS SELECT ...`
- `Loop` -> `SELECT * FROM loop(database, table)` (table function only)
- `MaterializedView` -> `CREATE MATERIALIZED VIEW name [TO target] AS SELECT ...`
- `WindowView` -> `CREATE WINDOW VIEW name [TO target] AS SELECT ... GROUP BY tumble(...)/hop(...)`

Also make the example query on the `system.table_engines` documentation page
explicit about the columns it shows, so the query and the displayed response
have the same shape.

#106177

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov and others added 2 commits June 2, 2026 20:34
The `description` and `syntax` column descriptions in
`system.table_engines` no longer matched the values returned: the
`description` field now often contains the full Markdown body of an
engine's documentation page rather than a short summary, and `syntax`
is no longer always an `ENGINE` clause now that `View`,
`MaterializedView`, `WindowView`, and `Loop` expose `CREATE ...` /
`SELECT ...` forms. Loosen both column descriptions so they accurately
describe the values.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/Storages/StorageJoin.cpp Resolved
Comment thread src/Storages/NATS/StorageNATS.cpp Resolved
alexey-milovidov and others added 2 commits June 5, 2026 07:36
Addresses the review comments on the embedded documentation:

- `system.table_engines` system-table page: sync the `description` and
  `syntax` column descriptions with the (loosened) source definitions in
  `StorageSystemTableEngines::getColumnsDescription`.
- `S3` / `COSN` / `OSS` / `GCS`: `registerStorageS3Impl` is shared by all
  four engines, but embedded the S3-specific page for every one. Keep the
  full page for `S3` only and give `COSN`, `OSS`, and `GCS` concise
  provider-specific descriptions pointing back to `S3`.
- `S3` / `AzureBlobStorage`: the default partition strategy is no longer
  `WILDCARD`. When `PARTITION BY` is used without an explicit
  `partition_strategy`, the default comes from
  `file_like_engine_default_partition_strategy`, which defaults to `HIVE`.
- `Iceberg` / `Paimon`: these are no longer plain aliases for `IcebergS3`
  and `PaimonS3`. They auto-detect the storage backend from the `disk`
  setting and default to the S3 implementation only when no `disk` selects
  another backend.
- `Join`: drop the `[TTL expr]` placeholders from the engine-specific
  `CREATE TABLE` syntax, since `Join` does not support column TTLs.
- `NATS`: rename `nats_consumer` to the actual setting `nats_consumer_name`.
- `RabbitMQ`: drop `rabbitmq_deadletter_exchange`, which is not a registered
  setting; dead-lettering is configured via
  `rabbitmq_queue_settings_list = 'x-dead-letter-exchange=...'`.

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

Copy link
Copy Markdown
Member Author

Merged latest master (the branch was ~559 commits behind and red) and addressed all the embedded-documentation review comments. All 7 review threads are resolved:

  • system.table_engines page — synced the description/syntax column docs in docs/en/operations/system-tables/table_engines.md with the loosened source definitions in StorageSystemTableEngines::getColumnsDescription.
  • S3/COSN/OSS/GCS — registerStorageS3Impl is shared by all four engines but embedded the S3-specific page for each. The full page is now kept only for S3; COSN, OSS, and GCS get concise provider-specific descriptions that point back to S3.
  • S3/AzureBlobStorage partition strategy — the default is no longer WILDCARD; when PARTITION BY is used without an explicit partition_strategy the default comes from file_like_engine_default_partition_strategy, which defaults to HIVE. Updated both blocks.
  • Iceberg/Paimon — described as default auto-detecting engines (dispatch to the S3/Azure/Local implementation based on the disk setting), instead of plain aliases for IcebergS3/PaimonS3.
  • Join — dropped the [TTL expr] placeholders, since Join does not support column TTLs.
  • NATS — nats_consumer → nats_consumer_name.
  • RabbitMQ — removed rabbitmq_deadletter_exchange (not a registered setting); dead-lettering is configured via rabbitmq_queue_settings_list = 'x-dead-letter-exchange=...'.

Built locally (ninja clickhouse, clean) and verified each fix by querying system.table_engines against the built binary.

The remaining CI failures on the previous SHA are unrelated to this documentation-only change:

@groeneai, could you investigate the test_paimon_incremental_read failure ( https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106177&sha=39b1915c82cf7e393efb4247e1c8f4f97b5b8e72&name_0=PR&name_1=Integration%20tests%20%28amd_msan%2C%201%2F6%29 ) and provide a fix in a separate PR? It is an assertion in the Paimon background-refresh path, unrelated to this PR. If a fix is already in progress, please link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Investigated. 04033_tpc_ds_q23 is a victim, not the cause.

In 4 of the 5 most recent failures the killed query asked for only 551 MiB to 1.03 GiB while RSS was already pinned at the 53.69 GiB host cap, so OvercommitTracker picked q23 only because the server total was already full from other concurrent queries. q23's own footprint is small and unchanged, so there is no q23-specific memory regression to bisect.

This is a runner-wide event on Stateless tests (arm_asan_ubsan, azure, parallel), not q23-specific:

  • OvercommitTracker OOMs on that check went from 1-8/day through 06-07 to 16 (06-08), 367 across 312 distinct tests and 29 PRs (06-09), and 339 across 265 tests and 50 PRs (06-10).
  • It hits master too (2, 2, 17, 16 over 06-07..06-10), and the 06-09 distribution is broad across many PRs, so it is not one bad PR.
  • The same spike does NOT appear on amd_asan_ubsan, distributed plan, parallel or arm_binary, parallel, so it is specific to the azure ASan parallel runner.
  • The host cap is unchanged at 53.69 GiB, so this is higher concurrent consumption, not a smaller cap.
  • Other victims of the same wave: 01603_read_with_backoff_bug (its own auto-issue Flaky test: 01603_read_with_backoff_bug #107037, identical Code 241 / RSS-at-cap signature), 03742_nested_loop_join_long, and many TPC-DS/TPC-H queries (q04, q50, q69, tpc_h_q05, tpc_h_q08).

Because q23's per-query ask is already under 1 GiB, no SQL setting on q23 can prevent this. The genuine fix is at the runner/memory-tracking level, and there are PRs already in flight for exactly this class: #106055, #104964, #104965, #104976.

The only q23-level mitigations are (a) no-parallel so it runs outside the high-RSS window while keeping full coverage, or (b) the q35-style echo SKIP disable. I held off opening a separate PR because (b) mirrors #106797 (q61, same root cause), where the reviewer has asked to replace the disable with regression analysis rather than skip the test.

Given q23 demonstrably did not regress, my recommendation is to let the systemic memory PRs above resolve it and not touch q23. If you prefer a q23-specific PR now, I would do no-parallel (preserves coverage) over a disable. Which would you like?

cidb session: cron:clickhouse-worker-slot-6:20260610-172400

alexey-milovidov and others added 2 commits June 13, 2026 03:00
The embedded `Paimon` doc and `iceberg.md` were already corrected to
describe the auto-detecting behavior, but the standalone `paimon.md`
still said `Table engine Paimon is an alias to PaimonS3 now`. Mirror the
embedded `registerStorageObjectStorage.cpp` wording so both copies stay
in sync.

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

Copy link
Copy Markdown
Member Author

Pushed bcab07c64fe..99de5f6c77c: merged current master (clean) and synced the standalone paimon.md page with the corrected embedded Paimon doc.

CI triage of the previous run (sha bcab07c64fe, all three failures were on the single Stateless tests (arm_asan_ubsan, azure, parallel) shard):

  • Logical error: Expected 3 to 10 arguments in table function azureBlobStorage — not a real logical error. At that sha the source already throws NUMBER_OF_ARGUMENTS_DOESNT_MATCH (commit 0a8e06f021c); this was the CI logical-error log-scanner tripping on the test text. It is fixed by f96ba01bb5e ("Stop test 04119 from tripping the CI logical-error log scanner"), which was not yet in bcab07c64fe but is included in this master merge. This PR is docs-only and does not touch src/Storages/ObjectStorage/.
  • Server died / OOM in dmesg — runner-wide total-memory OOM flake on arm_asan_ubsan (server OOM-killed by the runner cgroup, not a per-query limit), the same class seen on master and unrelated PRs.

@groeneai, the Server died / OOM in dmesg on the arm_asan_ubsan, azure shard looks like the recurring runner-wide total-memory OOM. Could you confirm and track it in a separate issue if one isn't open yet? Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106177&sha=bcab07c64fe0b38a77582b4d8fc6ae935285d276&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20parallel%29

Comment thread src/Storages/NATS/StorageNATS.cpp Resolved
Comment thread src/Storages/StorageJoin.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Confirmed. The Server died / OOM in dmesg on Stateless tests (arm_asan_ubsan, azure, parallel) at bcab07c64fe is the recurring runner-wide total-memory OOM (server OOM-killed externally by the runner), not a per-query max_memory_usage limit and not a per-test bug.

Evidence (CIDB, table default.checks):

  1. External kill, not an in-process throw. The OOM in dmesg row for that shard at this sha is the kernel reaper line, with no ClickHouse stack and no max_memory_usage exception:

    [ 4715.228520] oom_reaper: reaped process 5618 (clickhouse-serv), now anon-rss:0kB, file-rss:268kB, shmem-rss:0kB
    
  2. Runner-wide, not shard- or test-specific. At this single sha/run, OOM in dmesg fired on 38 distinct build/test shards (amd_debug, amd_tsan, amd_msan, amd_asan_ubsan, amd_llvm_coverage, arm_binary, arm_asan_ubsan azure parallel+sequential, ...). That breadth across unrelated shards in one run is a host-memory squeeze on the runner, not a per-shard regression.

  3. Not the multistage-distributed-queries UAF (Multi-stage distributed queries #106020). Zero heap-use-after-free / SIGSEGV with a ClickHouse frame on arm_asan_ubsan, azure at this sha. This is the genuine cgroup/host-OOM class, distinct from the UAF that Revert "Multistage distributed queries" (#106020) — fixes ASan heap corruption on master #107122 reverted.

  4. Recurring and self-resolving. Same Server died / OOM in dmesg signature on the arm_asan_ubsan, azure shard over 06-08..06-13 hit master (14 failures / 13 commits) plus 123 distinct unrelated PRs. Daily kill counts on that shard: 06-09=13, 06-10=93, 06-11=59, 06-12=6, 06-13=1, tracking the Revert "Multistage distributed queries" (#106020) — fixes ASan heap corruption on master #107122 revert of Multi-stage distributed queries #106020 (merged 06-11 01:37 UTC) that ended the box-wide memory storm.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106177&sha=bcab07c64fe0b38a77582b4d8fc6ae935285d276&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20parallel%29

Tracking issue status: there is no open umbrella issue for the runner-wide arm_asan_ubsan OOM (searched; none). #107037 (flaky test: 01603_read_with_backoff_bug) tracks one victim test only, not the class. I have drafted an umbrella infra issue (OvercommitTracker / host-RSS-cap evidence, cross-referencing the in-flight memory-tracking PRs #106055, #104965, #104976, and merged #104964); filing it on our side needs sign-off, so it is pending and I will link it here once filed.

@clickhouse-gh

clickhouse-gh Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🔴 AI verdict: degradation — 2 regressed, 4 improved out of 38 analysed

2 regressed query(s). K_source=6 K_base=30 flagged=6/65

clickbench

🟢 2 improved

Flagged queries (2 of 43)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
🟢 22 improvement 334 260 -22.2% <0.0001
🟢 23 improvement 297 206 -30.6% <0.0001

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🔴 2 regressed · 🟢 2 improved

Flagged queries (4 of 22)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
🔴 4 regression 3015 3432 +13.8% 0.0016
🔴 8 regression 156 188 +20.9% <0.0001
🟢 7 improvement 113 75 -33.6% <0.0001
🟢 20 improvement 248 131 -47.2% <0.0001

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 4ce41d21-c075-48f6-bf4a-fb65494fc5aa
  • MIRAI run: 6017593a-566e-491e-a26a-5df179573778
  • PR check IDs:
    • clickbench_94454_1781432703
    • clickbench_94468_1781432703
    • clickbench_94473_1781432703
    • tpch_adapted_1_official_94480_1781432703
    • tpch_adapted_1_official_94486_1781432703
    • tpch_adapted_1_official_94494_1781432703

Address review findings on the embedded table-engine documentation, fixing
both the embedded copies and the corresponding standalone Markdown pages so
the two stay in sync:

- `NATS`: `nats_reconnect_wait` default is `2000`, not `5000` (matches
  `NATSSettings`).
- `S3Queue`: rename the `enable_logging_to_s3queue_log` section to
  `enable_logging_to_queue_log` (the former is only an alias) and document its
  real default of `1`.
- `S3Queue`: `persistent_processing_node_ttl_seconds` default is `21600`
  (6 hours), not `3600`, and the same TTL is used for the `Ordered`-mode bucket
  lock.
- `AggregatingMergeTree`, `SummingMergeTree`, `CoalescingMergeTree`: embed the
  `Tuple element aggregation` section that was present only in the standalone
  pages.
- `Join`: use commas between `VALUES` rows in the examples to match idiomatic
  ClickHouse documentation.
- `PaimonS3`: remove the `[,structure]` argument from the table-engine syntax;
  table engines initialize object-storage configs with `with_table_structure`
  set to `false`, so `structure` is not accepted.
- `S3` and `AzureBlobStorage`: the `partition_strategy` default is
  compatibility-controlled (`WILDCARD` under `compatibility` older than `26.6`,
  `HIVE` otherwise), matching the standalone `s3.md` wording.

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

clickhouse-gh Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.80% 84.90% +0.10%
Functions 92.40% 92.40% +0.00%
Branches 77.30% 77.30% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 8917/8926 (99.90%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 3 line(s) · Uncovered code

Full report · Diff report

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

This is amazing - a huge progress!

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Filed the umbrella tracking issue: #108689.

Re-confirmed it is the runner-wide host OOM (server killed externally, not a per-query limit, not the #106020 UAF):

The early-June box-wide storm self-resolved tracking the #107122 revert (kills on the shard 06-09..06-13: 13, 93, 59, 6, 1). It now persists as low steady-state host-RSS pressure (~2-7/day on that shard). #107037 (the per-test victim issue) was closed, so there was no open umbrella tracker for the class. Cross-referenced the memory-tracking work in the issue (#106055 just merged, #104964 merged, #104965 / #104976 open).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements 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