Repository navigation
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-2:20260708-192900 |
|
cc @scanhex12 @alesapin — could you review? Fixes the Iceberg write-path OOB abort from #109835: |
|
Workflow [PR], commit [db91824] AI ReviewSummaryThe PR validates Iceberg write headers against the current schema, rejects compaction inputs the rewrite cannot safely handle, and preserves table metadata, the retention policy of Missing context / blind spots
Findings❌ Blockers — previously dismissed; retained for visibility, without reopening threads
Final VerdictStatus: ✅ Approve Approve the scoped fixes, accepting the existing decision to defer the pre-existing experimental-compaction defects to #124114. Normal CI gates still apply. No new inline comments or thread-state changes are needed. |
CI finish ledger — 4b88ce4 (superseded by master-merge 64cd00a)Every failure below has an owner. CI on 4b88ce4 finished (Finish Workflow success); the only red checks were the ThreadPoolCallbackRunner unit test across all sanitizers, whose fix (revert #109851) was on master but not yet on this branch. I merged master (64cd00a) to pick it up, so CI re-runs with the fix.
Session id: cron:our-pr-ci-monitor:20260709-033000 |
|
Good catch. Fixed in 7d1a8d6: the sink now compares the full current-schema-id ClickHouse schema (names + types) against The check reuses the shared Verified both directions locally with a same-width RENAME regression added to the test: on the count-only guard the RENAME insert silently succeeds (test fails), with the full-schema guard it is rejected (test passes, 5/5 with randomized settings). |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260709-043300 |
|
Pushed c047079: reconcile The full-schema (names + types) sink guard now rejects a stale-schema INSERT up front with
Updated 04329's two assertions and reference from |
|
@PedroTadim Good question. I checked the two mutation write paths in DELETE: not affected. A pure delete only emits position-delete files. UPDATE: yes, it shares the same class. Fix: I will extract the sink's full-schema (names + types) check into a shared helper and apply it in the mutate path for UPDATE, so INSERT and UPDATE stay in sync, and leave DELETE as-is with a source comment explaining why it is inherently safe. Regression will cover a same-width RENAME and a DROP COLUMN drift on UPDATE for Avro. |
|
Implemented in 622d5a1. The UPDATE path now runs the same full-schema guard as the sink (extracted into Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-2:20260709-073400 |
|
@PedroTadim good catch, UPDATE was not the only additional path. I enumerated every Iceberg path that writes data files through the positional block->field mapping +
No other mutation kind can reach I refactored the check into the shared |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260709-083800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260709-090400 |
Pre-PR validation gate — compaction schema-id-reuse guard (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260709-095400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260709-105100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-6:20260709-115800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260709-125100 |
`OPTIMIZE` built the committed metadata from `createEmptyMetadataFile` and copied back only the schema and partition-spec keys. So it replaced `table-uuid` with a fresh one, rewrote `location` to the bare table path, and dropped `properties` and the sort orders, while the rewritten data files keep their `sort_order_id`. A table attached with `iceberg_metadata_table_uuid` then fails with `FILE_DOESNT_EXIST` once the old metadata files are removed. Copy every key of the original metadata except the snapshot state (snapshots, refs, logs, sequence number, statistics), which compaction rebuilds from the plan. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.h
…ioned table Data compaction (writeMetadataFiles) built the metadata it commits from createEmptyMetadataFile(..., partition_by = nullptr, ...), so it committed an empty spec 0 (no fields, last-partition-id 999) while every rewritten manifest and the manifest list kept the source table's default spec and its partition tuples. Every later writer reads the committed spec: INSERT and ALTER ... DELETE wrote `[]` tuples, so the position deletes never matched the compacted files and the deleted rows stayed visible, and the next OPTIMIZE read 0 partition columns from the committed spec while the old files still carried 1-value tuples, which generateManifestFile reports as LOGICAL_ERROR "Iceberg manifest partition arity mismatch: 0 partition columns but 1 values" (aborts debug builds). Any second data OPTIMIZE on a partitioned table hits it; the emptied partition in the issue is not needed. writeMetadataFiles now copies partition-specs, default-spec-id and last-partition-id from the source metadata, so the committed metadata defines the spec (id, field ids, transforms) the rewritten manifests are written under. Only the partition keys are copied: schema preservation interacts with how the rewritten snapshots are stamped with the current schema id and is handled with its own refusal in ClickHouse#109838. Data compaction rewrites every data file under the default spec, so a tuple of another arity cannot be written (a table whose spec another engine changed to a different number of fields, or a table already compacted by an earlier version). compactIcebergTable now checks every data file's tuple against the default spec before writing anything and refuses with NOT_IMPLEMENTED; a missing default spec is ICEBERG_SPECIFICATION_VIOLATION (master dereferenced a null spec there). generateManifestFile keeps its LOGICAL_ERROR guards, since its other callers compute tuples from the spec they pass. Tests: a stateless test with the issue's two symptoms (a DELETE after OPTIMIZE, then a second OPTIMIZE), and a Spark integration case (DROP PARTITION FIELD) that checks the error, the rows, and that the refused OPTIMIZE writes no file. Closes ClickHouse#129498 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g-insert-column-count-oob-109835 Conflicts with ClickHouse#129564 (keep schema and partition spec in Iceberg `OPTIMIZE TABLE`): - `compactIcebergTable`: keep master's partition-tuple arity check (`NOT_IMPLEMENTED`) first, then this PR's stricter schema-id and partition-spec guards, sharing one lookup of the default spec. - `writeMetadataFiles`: this PR copies all table-level keys, which subsumes master's list of keys; keep master's `last-column-id` recomputation after the copy. - `test_optimize_position_delete_other_partition_spec`: keep this PR's expectation that `OPTIMIZE` is refused, and check that the metadata is unchanged; keep master's new tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
Design question for reviewers: on master, Local checks: the changed translation units and the |
Compaction applies only position deletes and regenerates only the history of the current snapshot under `main`. Three table shapes passed the existing checks and were silently corrupted: - live equality deletes: the rewritten files drop them, so rows removed by an equality delete come back (copy of the `data_minio/deletes_db/eq_deletes_table` fixture: 881 rows before, 980 after OPTIMIZE); - a ref other than `main` (tag or branch): the rebuilt metadata has only `main`, and `clearOldFiles` deletes the files the ref kept; - a snapshot outside the current snapshot's history (a branch, or main rolled back): every append is replayed in order, so the last one becomes current (main read [2] before OPTIMIZE and [2,3] after). All three are now rejected with NOT_IMPLEMENTED before any file is written. Master behaves the same (the equality-delete table becomes unreadable there instead). Found by clickhouse-gh[bot] review 5968980783 on ClickHouse#109838. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stale INSERTs of this test (after DROP COLUMN, DROP + ADD COLUMN, RENAME COLUMN and a nested field rename) are now refused by the input header check in the `IcebergStorageSink` constructor with BAD_ARGUMENTS, before `MultipleFileWriter` would refuse them with INCORRECT_DATA. The test still checks that no file is written and that the table keeps its rows; only the expected error changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rebuilt metadata starts from empty `refs`, and `generateNextMetadata` recreates `main` with only `type` and `snapshot-id`, so OPTIMIZE dropped `min-snapshots-to-keep`, `max-snapshot-age-ms` and `max-ref-age-ms` from `main`. A later `expire_snapshots` then falls back to the table policy and deletes snapshots the branch policy protected (measured: two manifest lists deleted with `min-snapshots-to-keep = 10` on `main`, none with the fix). Copy every field of the original `main` except its snapshot id onto the rebuilt one. Other references are already refused before any file is written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The history rebuild replays `snapshots` in array order and makes the last replayed append current, but the Iceberg spec does not tie that order to the parent chain (iceberg-rust, for one, serializes it from a hash map). With two appends listed out of order, OPTIMIZE committed the older append as current and `clearOldFiles` removed the originals (measured: rows [2, 3] became [2]). Every snapshot is already required to be an ancestor of the current one, so they form one chain; refuse unless each snapshot's parent is the snapshot listed before it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 4118ec4Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The other CIDB Session id: cron:our-pr-ci-monitor:20261119-120019 |
# Conflicts: # src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergWrites.cpp
…g-insert-column-count-oob-109835 Conflicts with the NDV statistics writer and the ORC timestamp fix: - `writeDataFiles` in `Compaction.cpp`: keep this PR's order (data file statistics are collected after the deleted rows are removed), with master's `ORC::replaceTimestampsStoredAsEpoch` before it and the `column_sketches` update after it. - `compactIcebergTable`: keep this PR's schema-id and partition-spec guards, then create master's `column_sketches`. - `IcebergStorageSink` constructor: keep both the partition spec check and `column_sketches`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
The only CI failure on the previous head was Local checks: the |
…g-insert-column-count-oob-109835 Conflicts: - `IcebergWrites.cpp`: master moved the reads of the latest metadata into `IcebergStorageSink::readLatestMetadata`. The `validateInputSchemaMatchesCurrentIcebergSchema` call of the first read now follows master's `checkFieldIdsKept`, and the checks of the retry (the schema and the partition spec redefined under the same id) moved into the retry branch of `readLatestMetadata`. - `Compaction.cpp`: kept the copy of all table-level metadata keys in `writeMetadataFiles`, which covers the keys master copies, including `properties`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
The only red check was |
OPTIMIZE rebuilds every snapshot through `generateNextMetadata` without a refresh cursor, and `carryForwardRefreshCursor` only inherits from rebuilt parents, so `clickhouse.refresh-cursor` disappears from the table. The next APPEND INCREMENTAL refresh of a materialized view targeting the table then finds no cursor (`RefreshTask` keeps no Keeper copy for a transactional target) and reads its source from the beginning, appending every row again. Measured: refresh (1), (2) into an IcebergLocal target, DELETE 1, OPTIMIZE, insert 3, refresh: the target held [1,2,2,3] instead of [2,3] (also on the master build 9f7ed31). Copy the cursor of the original current snapshot onto the rebuilt current one, next to the `refs.main` copy; the carried value is byte-identical. Reported by clickhouse-gh[bot] in ClickHouse#109838 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a server abort (out-of-bounds read) when writing into an
Icebergtable whose cached structure has more columns than its current Iceberg schema.INSERT,UPDATE,DELETEandOPTIMIZEnow reject a write whose columns no longer fit the current schema (a dropped, renamed or retyped column) withBAD_ARGUMENTS. FixedOPTIMIZEof anIcebergtable committing a renumbered schema, an empty partition spec and a new table UUID and dropping the refresh cursor, which made the table fail withschema-id 0 is bound to two different schemas, a laterDELETEon a partitioned table leave rows visible, a table attached byiceberg_metadata_table_uuidunreadable, and an incremental refreshable materialized view re-append its source.OPTIMIZEnow rejects live equality deletes, branches and tags, and rolled-back or out-of-order snapshots instead of resurrecting deleted rows, erasing the refs or making an older snapshot current. It also rejects live data files written under an older schema id or another partition spec, andUPDATEandDELETEreject a live data file whose partition spec id is not the default one.Description
Closes: #109835
On 26.7.1.644
IcebergStorageSinkmapped the input block's columns positionally onto the current schema's fields when it wrote per-column statistics, so an input block wider than the schema read past the end offield_idsand the server aborted. The fix validates the input header against the current schema: by name forINSERT, which may omit fields added after it was planned; positionally forUPDATE,DELETEandOPTIMIZE, which build statistics by position. Master'sINSERTrefuses such a block withINCORRECT_DATAsince #126768; this check runs first, sotest_writes_stale_insert_after_alter.pyexpectsBAD_ARGUMENTS.Also fixed here, each with a test:
OPTIMIZEkeeps the table-level metadata (schemas, partition specs, table UUID, location, sort orders, properties,main's retention policy) and the refresh cursor, and rebuilds only the snapshot state.OPTIMIZErefuses a table with a live data file written under an older schema id or another partition spec, since compaction rewrites every file under the current schema and default spec; on master a prunedSELECTthen misses rows of another spec.test_optimize_position_delete_other_partition_specnow expects it.UPDATEandDELETErefuse a live data file whose spec id is not the default one: readers apply position deletes only to data files of the same spec id.OPTIMIZErefuses live equality deletes, refs other thanmain, and snapshots outside the current history or out of commit order, which its replay cannot rebuild.Workflow [PR]
Sync PR [sync-upstream/pr/109838]