Repository navigation
Introduce MergeTree Queue Engine - #99509
Michicosun wants to merge 80 commits into
Conversation
|
Workflow [PR], commit [06da17c] Summary: ❌
AI ReviewSummaryThis PR introduces the experimental PR Metadata
Findings
Tests
Final VerdictStatus: LLVM Coverage ReportMeasured on commit 06da17c.
Changed lines: Changed C/C++ lines covered: 393/406 (96.80%) · Uncovered code |
980daf1 to
65371cf
Compare
Build profile diff (arm_release)Commit See the job log for details. |
`05023_merge_tree_sorting_key_virtual_columns` failed whenever the test runner randomized `enable_block_number_column` / `enable_block_offset_column` to 1, because the expected `BAD_ARGUMENTS` for a sorting key over disabled block columns never fired. Add the `no-random-merge-tree-settings` tag. `04042_merge_tree_queue_no_merging_modes` failed in the flaky checks with `TABLE_ALREADY_EXISTS: Mapping for table with UUID=... already exists`: the full-definition `ATTACH` cases used hardcoded UUIDs, and the UUID mapping is server-global, so concurrent or repeated runs of the test collide. Move those cases to a new shell test, `05045_merge_tree_full_definition_attach_validation.sh`, which generates a fresh UUID per run. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99509&sha=dffb3042c8f3982f9a134605130c9b41e51c46a3&name_0=PR PR: #99509 Co-Authored-By: Claude Fable 5 <[email protected]>
Addresses the three AI-review blockers on the validation introduced for sorting keys over MergeTree virtual columns: * The validation in `registerStorageMergeTree` ran only for `args.mode <= CREATE`, so a full-definition `ATTACH TABLE ... UUID '...' <definition>` bypassed it. Key it off the fresh-definition condition already used for the TTL and queue validation (the flag is renamed to `is_fresh_table_definition` since it is no longer queue-specific). * The `ALTER MODIFY/RESET SETTING` guard for `enable_block_number_column` / `enable_block_offset_column` was queue-only, but a regular `MergeTree` can now declare a sorting key over these columns too, and disabling the settings afterwards would leave the next merge unable to materialize the key columns. Reject disabling a setting whenever the current sorting key requires the corresponding column. * The post-commit primary-index repair (`IMergeTreeDataPart::correctVirtualColumnsInIndex`) rewrites only a bare `_block_number` key column. A key expression over `_block_number` (e.g. `_block_number + 1`, or one mixing it with real columns) cannot be recomputed from the stored index values, so a level-0 part would keep an index built from the placeholder written at insert time, silently breaking key-condition pruning. Reject such key expressions at `CREATE`: the real value is assigned only when the insert commits, and the bare column is the only repairable (and the only meaningful) form. PR: #99509 Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 Merged CI failures (both in the tests added with the sorting-key validation on 2026-08-19):
AI-review blockers (details in the thread replies):
All 15 tests of the PR pass locally against the rebuilt binary; CI of the previous head: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99509&sha=dffb3042c8f3982f9a134605130c9b41e51c46a3&name_0=PR |
…26.9 block The setting was recorded under 26.8, but 26.8 has been released without this change, so the `settings_changes_history` style check demands the record under the current version block (26.9). https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99509&sha=2667e1a3d1270dbb320531ac4c5cc8336cd2b1c3&name_0=PR&name_1=Style%20check #99509 Co-Authored-By: Claude Fable 5 <[email protected]>
…gine # Conflicts: # src/Storages/MergeTree/registerStorageMergeTree.cpp
|
🕵 Fixed the only CI failure (Style check, Verified locally with the branch binary: incremental build is clean, all 15 queue/commit-order tests pass (04032, 04037–04044, 04145, 04695, 04726, 05023, 05045), and |
…gine # Conflicts: # src/Storages/MergeTree/MergeTreeDataWriter.cpp # src/Storages/MergeTree/MergeTreeDataWriter.h
|
🕵 Updated the branch: merged Conflicts were mechanical, in one place: master added a Verified locally: incremental The only CI red on the previous head was Review state: zero unresolved review threads, and the AI Review verdict on the previous head was "✅ No actionable findings in the current code". The remaining open item is still a design call for the author/maintainer: whether to extend the queue-engine contract to cover partitioning instead of rejecting |
|
Confirming it is owned and not dismissed, with one correction to the pointer.
That carrier is fixed by #112968 (merged 2026-09-03 22:37Z in #118722 and #118359 are mine, but they track the |
…gine # Conflicts: # src/Core/Settings.cpp # src/Core/SettingsChangesHistory.cpp # src/Storages/MergeTree/registerStorageMergeTree.cpp # tests/queries/0_stateless/04726_streaming_queries_commit_order_snapshot_plan.reference
…xpression The rejection of key expressions over `_block_number` (only the bare column can be repaired in the primary index of a level-0 part) walked the original sorting-key AST. `InterpreterCreateQuery::createTable` inlines SQL user-defined functions before the storage sees the definition, so a `_block_number` hidden in a UDF body was already rejected through DDL, but the invariant depended on that interpreter ordering. Analyze every key element the same way `KeyDescription::getKeyFromAST` analyzes the whole key and reject an element whose resolved dependencies include `_block_number`, so the check holds regardless of how the expression was spelled. Regression cases with SQL UDFs added to `05023_merge_tree_sorting_key_virtual_columns`, including a UDF that expands to the bare column, which is a valid bare key. Addresses the AI review thread on #99509 Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 Updated the branch: merged Conflicts were mechanical, in four files: The review thread fix: the bare- Verified locally: incremental @groeneai, thanks for the correction on the The remaining open item is unchanged and is a design call for the author/maintainer: whether to extend the queue-engine contract to cover partitioning instead of rejecting |
…gine Conflict in `04040_commit_order_projection_merge_levels`: master fixed the `part_log` race of this test in the `.sql` version (drop the table before `SYSTEM FLUSH LOGS`, bound `SYSTEM SYNC MERGES` with `max_execution_time`), while this branch had converted it to a `.sh` with a `sleep` retry loop. Took master's `.sql` (no sleep loop) and kept this branch's expectations (`level-1 merges` label; projections are merged, never rebuilt). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Master bumped the version to 26.10, so the style check requires the record under the current block. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`IMergeTreeDataPart::setIndex` called `correctVirtualColumnsInIndex`, which looked up the part's metadata with `getMetadataSnapshot`, i.e. from the current metadata of the table. An `INSERT` writing parts with the snapshot it took at query start still materializes a projection that a concurrent `ALTER TABLE ... DROP PROJECTION` has already removed, so the lookup threw `NO_SUCH_PROJECTION_IN_TABLE` and failed the insert (`05201_check_table_dropped_projection` in the Fast test). The same applies to the synthetic projection part of `WhatIfProjectionEstimator`, whose projection need not exist in the table at all. Pass the metadata the index was computed with to `setIndex` explicitly. `loadIndex` keeps using the snapshot it already takes. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=99509&sha=8b78891f5ae47a68dda3ff932a09d19b4ebdafc7&name_0=PR&name_1=Fast%20test #99509 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Merged master (the PR was
Checked locally: incremental build is clean; all 15 PR tests, |
| /// `createTableFromAST`), and `SECONDARY_CREATE` (DDL replay in `Replicated` databases, `RESTORE`) | ||
| /// also replays previously validated definitions - those must stay loadable regardless of the | ||
| /// current settings. | ||
| const bool is_fresh_table_definition = args.mode <= LoadingStrictnessLevel::CREATE |
There was a problem hiding this comment.
This fresh-definition split is exactly what the projection feature gates are still missing. MergeTreeData treats every LoadingStrictnessLevel::ATTACH as attach = true (src/Storages/MergeTree/MergeTreeData.cpp:823), so a full-definition ATTACH TABLE ... UUID '...' (...) ENGINE = MergeTree ... PROJECTION ... is handled like metadata replay there and skips the CREATE-only allow_commit_order_projection / allow_part_offset_column_in_projections gates.
That leaves a fresh-input bypass: with allow_commit_order_projection = 0, the equivalent CREATE TABLE throws, but a full-definition ATTACH still accepts a projection using _block_number / _block_offset. Could we reuse is_fresh_table_definition for those projection gates too (or validate them earlier in registerStorageMergeTree), and add a regression next to 05045_merge_tree_full_definition_attach_validation?
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Introduced the experimental
MergeTreeQueueandReplicatedMergeTreeQueueengines, which keep rows in commit order using the engine-managed_block_numberand_block_offsetsorting key. Enable theallow_experimental_merge_tree_queuesetting to create such a table. This is built on top of support for arbitrary virtual columns in the MergeTree sorting key, which lets data be sorted by insertion order without duplicating it in a projection.Workflow [PR]
Sync PR [sync-upstream/pr/99509]