Repository navigation
Use merge_use_batch_sorting_queue for lightweight delete, TTL, patch part and DEDUPLICATE merges - #133262
Conversation
The sorting queue of an `Ordinary` merge now depends only on `merge_use_batch_sorting_queue`. The removed `!merge_may_reduce_rows` term kept lightweight delete, TTL delete, patch part and `OPTIMIZE ... DEDUPLICATE` merges on the default queue. It came from the review of ClickHouse#108468 (ClickHouse#108468 (comment)) for missing coverage, not for a defect, like the projection term removed in ClickHouse#132085. Only `MergingSortedTransform` receives the strategy; the other merging algorithms already use a batch queue of their own, so the setting description now says the setting has no effect on them instead of "keep using the default queue". The other uses of `merge_may_reduce_rows` (projections, text indexes, statistics, minmax index rebuild) are unchanged. In horizontal merges the merge itself sees plain sorted streams: lightweight deleted rows are filtered at read, patch parts are applied at read, expired TTL rows are dropped by `TTLStep` after the merge, and `DEDUPLICATE` runs a `DistinctStep` after the merge. Vertical lightweight delete and TTL delete merges now run the batch queue's row-mask code in `MergingSortedAlgorithm::insertRows` for the first time. The new test compares the merged parts under both queues for each case (row counts and a hash of the content with `_part_offset`, `_block_number` and `_block_offset`). Requested in ClickHouse#132085 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (2 nits, no action).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261120-154100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261120-135500 |
|
Workflow [PR], commit [ee52f67] Summary: ✅
AI ReviewSummaryReviewed #133262 at Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 24 s compile time in total, 8 of them have a recent master baseline. |
CI finish ledger - 3a1e909Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261120-190022 |
|
@groeneai |
The test ran over 180 s in every flaky-check run with ASan, s3 storage and meta in keeper in the private CI. Its cost is the number of merges, part copies and mutations, not the row count: under the thread fuzzer a merge of 100 rows costs nearly as much as one of 400, and most of it is waiting, not CPU. Use 100 rows in 3 parts instead of 400 in 4, drop the `k` column, give the lightweight delete and the patch parts one set of tables (both are applied at read, and the vertical merge still takes the row mask path), run the `DELETE` once on the seed before copying its parts, and set the merge settings in `CREATE TABLE ... AS ... SETTINGS` instead of an `ALTER ... MODIFY SETTING` per table. The TTL delete cases move to 05838_merge_batch_sorting_queue_row_changing_merges_ttl, so each file carries about half of the remaining work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in ee52f67, and master is merged (it brings #133270).
The cost was the number of merges, part copies and mutations rather than the rows: under the thread fuzzer a vertical merge of these parts took about 6 s of wall time for 0.9 s of CPU. Debug build, thread fuzzer on, 8 copies on 16 CPUs (the flaky check's shape), p50 per run: the old file 214-250 s, now 58 s and 33 s for the two files. I did not add a settings bound: over 50 randomized runs no setting moved the time much, and the tables already pin A throw at the top of |
Related: #132085
Related: #108468
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
With
merge_use_batch_sorting_queueenabled, merges that drop or rewrite rows (lightweight deletes, TTL deletes, patch parts of lightweight updates andOPTIMIZE ... DEDUPLICATE) now also use the batch sorting queue. With the setting enabled, such merged parts can be split into blocks differently than on previous versions. The data is the same, but in aReplicatedMergeTreecluster with replicas on different versions this can show up as a harmless "not byte-identical" checksum mismatch, after which the replica downloads the merged part from another replica.Description
Asked for in #132085 (comment). The
!merge_may_reduce_rowsterm came with the projection term from #108468 for missing coverage (#108468 (comment)), not for a defect. Nowmerge_use_batch_sorting_queuealone chooses the queue of anOrdinarymerge. OnlyMergingSortedTransformreceives it; the other merging algorithms already use their own batch queue, which the setting description now says instead of "keep using the default queue". The other uses ofmerge_may_reduce_rowsare unchanged.In horizontal merges the merge sees plain sorted streams: lightweight-deleted rows and patch parts are handled at read, expired TTL rows are dropped by
TTLStepafter the merge, andDEDUPLICATEruns aDistinctStepafter it. Vertical lightweight delete and TTL delete merges now run the batch queue's row-mask code (MergingSortedAlgorithm::insertRows,bfb72a13736d) for the first time.The new tests compare the merged part under both queues in horizontal and vertical merges (lightweight delete with patch parts, and
DEDUPLICATE, in one; TTL delete in the other): row counts and a content hash with_part_offset,_block_numberand_block_offset.Release build,
OPTIMIZE ... DRY RUNof 10 overlapping parts of 1M rows, setting on / off on one binary (off = the default queue, as on master), medians of 12 runs:MergingSortedMillisecondsVertical merges gain less because masked rows are still inserted one by one. With the setting forced on, none of 881 existing lightweight delete, TTL, patch part and deduplication tests fails only with this change.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/133262]
Version info
26.12.1.309-master(included in26.12and later)