Repository navigation
UNIQUE KEY: merge - #123013
UNIQUE KEY: merge#123013murphy-4o wants to merge 36 commits into
Conversation
…snapshot, and commit through UniqueKeyTxnCommit::merge - MergeTask captures the input bitmaps at merge start (captureUniqueKeyMergeInputBitmaps), drops dead rows from the inputs (MergeTreeSequentialSource, RangesInDataPart::delete_bitmap), builds MergedPartOffsets for every unique-key merge, keeps the text-index merge off that mapping, merges horizontally, and writes the merged part's dense index with SSTIndexWriter before finalizePart; UniqueKeyDenseIndexOps::writeDenseIndexOnMerge goes. - MergePlainMergeTreeTask commits under its own uk_txn through UniqueKeyTxnCommit::merge. The task's transaction begins once its sources are visible (beginUniqueKeyTransaction waits out a source still inside its commit), so its snapshot covers their creation; a rolled-back result is dropped from the working set so a retry can reuse its name. - OPTIMIZE and background merges run; the TTL case and DEDUPLICATE are refused (checkUniqueKeyOptimizeIsPossible, selectPartsToMerge, optimizeDryRun), and the TTL comments stop saying merges are disabled. - The unique_key_merge_pause_before_commit and unique_key_merge_fail_after_publish failpoints, the transaction_hold_unknown_state hook in TransactionManager, the UniqueKeyMergeInputRowsSkipped ProfileEvent. - Tests: 04109 cases 1-4, 04159, 04173, 04185, 04194 case 2, 04158_optimize_rejected deleted; 04168 case 1's merge lines, 04171 case 1, 04163 case 5's merge lines. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Workflow [PR], commit [cf6e525] Summary: ✅
AI ReviewSummaryEnables horizontal and vertical merges for experimental Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Make merge commit waits cancellable, enforce the duplicate-trackers' memory limit, and address or explicitly track the remaining dismissed concerns. Supply regression coverage for the repaired corruption checks and CI results for the new merge tests. |
Build profile diff (arm_release)Commit See the job log for details. |
The merge passes its merge-list flag to the commit, so a background merge waiting on a lost commit reply gives up once shutdown cancels it instead of holding shutdown. Removing a rolled-back merge result is retried while a reader holds it, so an immediate retry of the merge can reuse its name. A merge no longer refuses while a transaction is undetermined. 04173 kills the stranded INSERT before its checks, fails loudly when a wait times out, keeps the late-kill tables' key column dense and reads part names from system.parts, and its refusal case goes; 04185 reads part names from system.parts. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…un 04185 alone Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t/merge Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t/merge Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t/merge Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…vate Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… the row map Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ueries_probability Under `ignore_drop_queries_probability` a DROP of a table that does not store data on disk was rewritten to TRUNCATE. For object storage tables (`ENGINE = S3/Azure/HDFS/...`, also through the `s3://` URL delegate), `Alias` tables and `CREATE TABLE ... AS <table function>` proxies that TRUNCATE acts on data outside the server: it deletes the remote objects, empties the alias target, or truncates whatever the table function points at. A real DROP of the same table touches none of it. On an unreachable endpoint the TRUNCATE retries for ~41 minutes (500 attempts, 5 s backoff cap) while holding the table's DDL guard. In the Upgrade check (amd_release) on PR ClickHouse#123013 the faked DROP of 05059's `ENGINE = S3('http://localhost:19999/dummy.parquet', ...)` table hung this way; a later `DROP DATABASE` of the shared stress database then prepared every table for shutdown (bricking the replica of `t_lightweight_mut_3`) and blocked behind it holding `restart_replica_mutex`, so the pre-upgrade cleanup could neither kill the leftover replicated mutation (TABLE_IS_READ_ONLY) nor restart the replica (ABORTED). Such DROPs are now ignored, as for tables that store data on disk. The table survives either way, so the set of tables left behind by Stress and the Upgrade check does not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…flag on the merge commit, 04168 merge case Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # src/Storages/MergeTree/MergeTreeData.cpp # src/Storages/MergeTree/MergeTreeData.h
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The dense index stores row numbers as UInt32, so a merge past that failed after writing the whole part and was selected again. Join the text and vector similarity indexes in the stock merge row cap instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`toMergedRow` counted the dead rows before each index entry with `rank`, which walks every container before the row. Cache the dead rows before each container per source, and count a range with `roaring_bitmap_range_cardinality_closed`, which reads only the containers it covers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A fresh ATTACH TABLE could still create a UNIQUE KEY table with a stored `_part_index` column, whose merges then read it as the source index. UNIQUE KEY tables are experimental, so no stored metadata needs the exemption. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # src/Common/ProfileEvents.cpp # src/Storages/MergeTree/MergeTask.cpp
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/MergeTree/MergePlainMergeTreeTask.cpp # src/Storages/MergeTree/MergeTask.cpp # src/Storages/MergeTree/MergeTask.h # src/Storages/MergeTree/UniqueKey/DeleteBitmap.h
Mark the unique-key merge accessors [[nodiscard]] and bound 04197's system.text_log scan by event_time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…merge, review trims - The merge row map rejects source rows past the part (snapshot bitmaps and late kills), and the merged dense-index build rejects a source index that maps two keys to one row, both with CORRUPTED_DATA. - A background merge on a unique-key table runs under its own transaction instead of keeping the one it was selected under open and committing it after the merge. - The merged dense-index builder is a free function; UniqueKeyMergeInputRowsSkipped is dropped (input_rows_filtered counts it); the transaction overload of makeDeleteBitmapSnapshot is private. - Comment, naming and test trims; master's include order and 04171 case numbers are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| part.name, entries, part.rows_count); | ||
|
|
||
| SourceCursor cursor{ | ||
| .source_index = i, .part = &part, .reader = reader, .iterator = reader->newIterator(), .seen_rows = std::vector<bool>(part.rows_count)}; |
There was a problem hiding this comment.
[Major] Enforce the memory limit for the per-row duplicate tracker
seen_rows now allocates one bit per physical source row for every source before the SST scan starts. A permitted merge near the UInt32 row limit therefore allocates about 512 MiB here, even for ORDER BY tuple() where no full row mapping is needed. With the default min_allocation_size_to_throw_on_memory_limit = 0, allocations through std::allocator are counted but never refused by the memory tracker. Constructing and zeroing these vectors can consequently exceed the background/server memory limit before a later tracked allocation gets a chance to stop the merge; concurrent merges multiply that excess.
Use VectorWithMemoryTracking<bool> for seen_rows (including its construction here), so the duplicate-offset validation can raise MEMORY_LIMIT_EXCEEDED before allocating its row-sized buffer. This container stays local to the cursor, so no interface conversion or copy is needed.
Part of #103486
OPTIMIZE ... DEDUPLICATEand TTL merges are refused.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/123013]