Repository navigation
Write one Iceberg position delete file per data file in ALTER UPDATE and DELETE - #129380
Conversation
…les up by path ALTER UPDATE and DELETE collect the deleted positions of each data file in a roaring bitmap and write one position delete file per data file, rows sorted by pos, with file_path lower == upper bounds; the files of a partition share one manifest. Reads group the position delete files whose bounds name one data file by that path once per query, so a data file looks its own up instead of walking every delete file of its partition. The pruning counters keep their totals. A failed mutation removes the delete files it already wrote. 04291 (ClickHouse#91525) gets a part reading a Spark-written fixture whose delete file covers several data files, since ClickHouse no longer writes one; 05229 pins the manifest-list file count of a multi-file DELETE; the setup checks of iceberg_deletes_scale.xml accept both layouts. Analysis and the writer patch: issue ClickHouse#129159. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove comments that narrate the new code in Mutations.cpp and shorten the rest to the invariants they state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (rounds 1-4): 8 findings fixed, 1 out of scope, 5 noted
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261104-204200 |
|
cc @scanhex12 @alesapin, could you review this and add the |
|
Workflow [PR], commit [681cb9c] Summary: ✅
AI ReviewSummaryReviewed #129380 at Consumers checked for the changed file layout:
Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes7 object files changed (+38.02 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units74 translation units recompiled, 1061 s compile time in total, 74 of them have a recent master baseline. |
In the DBReplicated stateless job the ALTER on an IcebergLocal table is executed once per shard (DatabaseReplicated::shouldReplicateQuery returns true for a non-replicated table when the cluster has several shards), and every server sees the same files. The shard-2 server re-ran `UPDATE s = 'x' WHERE n % 5 = 0` after the initiator, matched the 857 rows the first run had just written, and added one data file and one delete file (DATA 12 / POSITION_DELETE 21 instead of 11 / 20). The DELETE statements already match nothing on a second run. `AND s != 'x'` makes the second run a no-op, so the counts no longer depend on the database engine. Checked on a local two-shard Replicated database rig: the unchanged test fails 5/5 with the CI diff, the changed one passes 20/20 there and 20/20 on an Atomic database, both with randomized settings, and still fails against a master server. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/Mutations.cpp
…illed query while writing A position delete file was added to the mutation's file list only after it had been written, so an exception while writing it left a file that the cleanup of the failed mutation did not see. Besides I/O errors, this is what a KILL QUERY or max_execution_time during the write phase does: the Parquet writer reports the cancellation from its finalize, and the delete file it was writing stayed in the table directory. The file is now registered before its object is created. The delete files are written after the read pipeline has finished, and the Parquet writer checks for a killed query only with parallel encoding. With max_threads = 1 a killed or timed-out DELETE wrote all its delete files and committed the snapshot, although the client received the error. Check the query status for every block and after the last upload, so such a mutation fails and its files are removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: No performance changes are attributable to this PR. It changes only Iceberg code: delete files are now looked up by data file path when reading, and ALTER DELETE/UPDATE writes one position delete file per data file. ClickBench and TPC-H here read local MergeTree tables and never run that code. Two ClickBench queries were flagged but stay inconclusive. Q28 (+5.6%) is a borderline result where the two tests disagree. Q31 (+11.6%) is inside master's normal range for that query and is noisy on master, so that suppression is consistent with the diff. clickbenchFlagged queries (2 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. 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🟢 No significant changes Debug info
|
…-spec Resolve the Mutations.cpp conflict with ClickHouse#129380, which writes one position delete file per data file: the DELETE pass now collects the deleted positions by data file only, and each data file's delete file is grouped under the spec id, schema id and partition tuple recorded in its manifest entry, instead of the partition recomputed from row values with the default spec. Master's per-partition manifest writer takes the spec, partition columns and types as arguments, so delete manifests are written under the recorded spec while new UPDATE data files keep the default one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #129159
Related: #128374
Related: #120916
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg
ALTER TABLE ... UPDATEandDELETEwrite one position delete file per data file, with positions in increasing order, as Spark does by default, and reads look such delete files up by data file path, so each data file reads only its own deletes. Reads after such mutations are 6-9 times faster in the Iceberg configuration of theapply_patch_parts_mergeperformance test.Description
Problem. A mutation kept one position delete writer per partition and read data files in parallel, so each delete file mixed positions of many data files and its
file_pathbounds covered almost all of them.IcebergIterator::nextprunes by those bounds, so every data file opened every delete file.Change. Deleted positions are collected per data file and written as one delete file per data file, sorted by
pos, with exact bounds; the files of a partition share one manifest. On read, delete files whose bounds name one data file are looked up by path, so a data file no longer walks the delete files of other data files. A failed mutation removes the delete files it already wrote.Measured (release, x86, Iceberg local disk, 10 paired runs; perf tests via
perf.py --table-engine iceberg_local):apply_patch_parts_mergeM0-M3 -84..-89%,apply_patch_parts_stepsS0/S1 -78/-82%; 20 UPDATEs 315 s -> 118 s, UPDATE peak memory 1.94 GiB -> 531 MiB. 2000 data files x 5 sparse DELETEs (10,000 delete files):count()-40% local, -15% S3, -15..-32%icebergLocalCluster. Losing shape:lightweight_deleteL0 +10..15%: its one-thread DELETE writes master's single file in data-file order, so it is pruned by row group, while the 10 per-file files are read whole.Side effects. Tables have more, smaller delete files; their
posorder covers the goal of #120916.Skipping position delete fileis logged only for files not bounded by one data file.05325T2 and a new part of04291read Spark-written fixtures,05229covers a multi-file DELETE manifest, andtest_iceberg_inverted_delete_bounds.py,test_position_deletes_bounds_loggingand the setup checks oficeberg_deletes_scale.xmlfollow the new layout.Patch and analysis by @ snelheidai in #129159.
Workflow [PR]
Sync PR [sync-upstream/pr/129380]
Version info
26.12.1.61-master(included in26.12and later)