Repository navigation
Refuse to read Apache Paimon tables with deletion vectors instead of returning deleted rows - #122506
Conversation
On a Paimon table with 'deletion-vectors.enabled' = 'true', a row-level UPDATE or DELETE does not rewrite data files: the writer commits a COMPACT snapshot whose index manifest holds a deletion vector (a RoaringBitmap of deleted row positions) for the affected data file. PaimonMetadata::iterate returns the union of the snapshot's data files and never reads the index manifest, so every row a deletion vector removed is returned. The ClickHouse#113460 guard refuses only primary-key tables, so append-only tables passed it. Throw NOT_IMPLEMENTED when the pinned schema sets the option, right after the primary-key check and above the read-mode split, so full scans, paimon_target_snapshot_id and incremental reads are all covered, and a refused incremental read never advances the Keeper watermark. The option is the exact condition under which Paimon's own reader applies deletion vectors. Tables with the option set but no delete yet now throw too; refusing only when the index manifest carries deletion vectors would need an index-manifest reader and a table-state protocol change. The fixture was written by Spark 3.5.9 with paimon-spark-3.5 1.1.1; its README has the recipe. Closes ClickHouse#122431 Co-Authored-By: Claude Opus 5.5 <[email protected]>
05259 now also refuses a copy of the deletion-vector table whose option is spelled 'TRUE', checks that the refused incremental read leaves no committed_snapshot under the table's Keeper path, and reads a copy of paimon_no_partition with the option set to 'false'. The new refusal line and the watermark line both fail on the unfixed binary; the 'false' copy is a positive control that reads on both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove the comment above the deletion-vector guard; the exception message below states the same. 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; 2 findings in round 1, 0 after the fix round) plus my own cold review of each round.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260927-044600 |
|
Workflow [PR], commit [a6a5aeb] Summary: ✅
AI ReviewSummaryThis change refuses Apache Paimon snapshots with live deletion vectors instead of returning deleted or superseded rows. It checks the snapshots used by full, targeted, and incremental reads, preserves the incremental cursor on refusal, and documents recovery. No actionable findings remain in head Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; required CI must finish before merging. |
Base the deletion-vector refusal on the index manifest of every snapshot
that is actually read (full scan, `paimon_target_snapshot_id`, incremental
reads) instead of the `deletion-vectors.enabled` schema option. The option
can be turned off while the index manifest still lists live deletion
vectors, so the latest schema can say 'false' for a snapshot that has them.
The check runs in `collectDataFilesFromManifests`, which every read mode
goes through, before any Keeper watermark is committed. It re-reads the
snapshot file by id because the index manifest name is not part of the
serialized table state. A snapshot without deletion vectors (for example,
one written before the first delete) is read as before.
Paimon writes only live entries into an index manifest, and its reader
treats every `DELETION_VECTORS` entry as live, so a snapshot has deletion
vectors iff its index manifest has such an entry.
New fixture `paimon_append_deletion_vectors_disabled`: the deletion-vector
table after `ALTER TABLE ... SET TBLPROPERTIES ('deletion-vectors.enabled'
= 'false')` and one more insert, without a full compaction.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tors A resumed incremental read skips `COMPACT` snapshots, but its watermark still moves past them. The compaction that adds a deletion vector is one of them, so with only the data-file check a reader at snapshot 2 that reached snapshot 3 returned nothing and committed 3 instead of throwing. Check each skipped compaction too, outside the catch-all for missing snapshots so the error propagates. 05259 replays the writer's commit of snapshot 3 for a reader that consumed snapshot 2 and asserts the refusal and the unchanged watermark. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When compaction removes the last deletion vector of a bucket, Paimon writes an empty `DELETION_VECTORS` index file (`_ROW_COUNT` 0) that replaces the old one, and its reader applies nothing from it. Count only entries with deletion vectors, so a fully compacted bucketed table reads again. New fixture `paimon_append_deletion_vectors_compacted`: a bucketed deletion-vector table after an UPDATE and a full compaction. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-paimon-deletion-vectors
`hasDeletionVectors` joined the snapshot's `indexManifest` to the table path without validation, so an absolute path or `..` made ClickHouse open a file outside the table root before deciding whether the snapshot is readable. Validate it with `checkPathIsRelativeToTable`, like the manifest list and manifest readers, and cover both shapes in 05301. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes198 object files changed (+104.49 KiB total), 0 added.
719 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 units840 translation units recompiled, 6488 s compile time in total, 840 of them have a recent master baseline. |
|
@groeneai This PR adds too many test data files. Could we generate these files at test runtime instead? For example, dynamically invoke the corresponding JARs or Spark programs at runtime. |
|
Agreed. I'll drop |
Replace 05259 and its three Spark-generated fixture directories with an integration test that writes the tables at runtime with the Paimon Spark bundle baked into the integration runner image (paimon-spark-3.5 1.1.1, the writer that produced the fixtures), as test_paimon_spark_smoke does. The arms are the same: a full scan and count() of a table with a deletion vector are refused, also after deletion-vectors.enabled is turned off without a full compaction; a table whose full compaction applied the deletion vector is read; a targeted read of the snapshot that added it is refused while the one before is read; an incremental reader that already consumed snapshot 1 is refused at the skipped COMPACT snapshot and keeps its watermark, and a fresh incremental reader is refused and records none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in e690f27: |
The deletion-vector check re-read `snapshot/snapshot-<id>` at execution time only to get its `indexManifest`, although the state pinned during analysis came from that same file. A full scan therefore opened the snapshot file twice, and the targeted and incremental reads loaded every snapshot twice. The pinned state was also no longer sufficient to execute the read. Carry `indexManifest` in `Paimon::TableStateSnapshot` (in memory and in its serialization) and check the state that is actually read. Measured with strace on a full scan: `snapshot-N` is opened 2 times before, 1 time after; the refusal and the results are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`Paimon::TableStateSnapshot` gained the serialized `index_manifest` field in 2147cac, but `DATA_LAKE_TABLE_STATE_SNAPSHOT_PROTOCOL_VERSION` stayed 1, so a buffer written with the version 1 layout failed to decode ("Attempt to read after eof") and an older reader could not tell the new layout apart. Bump the protocol version to 2, read the index manifest only for version 2, and keep decoding the version 1 layout of every format. The outer and Iceberg layouts did not change, so both accept versions 1 and 2. Unit tests: a round trip of the Paimon state with and without an index manifest, and a hand-written version 1 Paimon buffer that must still decode. The latter fails on the previous head and passes with this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged master ( |
…-paimon-deletion-vectors
CI finish ledger - 5ab27c5Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The other Session id: cron:our-pr-ci-monitor:20261012-193011 |
The data-lake table state serializer wrote the global maximum protocol
version for every variant, so bumping it to 2 for the Paimon index
manifest also relabeled unchanged Iceberg and Delta Lake buffers as v2,
which older peers reject ("maximum supported version is 1"). Write each
variant with the lowest version that has its layout: 1 for Iceberg and
Delta Lake, 2 for Paimon. Decoders still accept both.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| static constexpr auto DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION = DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_ICEBERG_DELETION_VECTORS; | ||
|
|
||
| static constexpr auto DATA_LAKE_TABLE_STATE_SNAPSHOT_PROTOCOL_VERSION = 1; | ||
| static constexpr auto DATA_LAKE_TABLE_STATE_SNAPSHOT_INITIAL_PROTOCOL_VERSION = 1; |
There was a problem hiding this comment.
The new Paimon field should not change the shared state protocol version or the Iceberg deserializer. serializeDataLakeTableStateSnapshot and deserializeDataLakeTableStateSnapshot still have no callers outside the gtest, so no build has ever written or read a Paimon state, and there is no version 1 Paimon layout to stay compatible with. cc @groeneai
There was a problem hiding this comment.
Done in 2c13034af01c4: ProtocolDefines.h, DataLakeTableStateSnapshot.cpp and the Iceberg deserializer are back to master, and index_manifest is read as part of the version 1 Paimon layout. I confirmed both functions are called only from gtest_datalake_table_state_serde.cpp; the gtest now keeps just the Paimon round trip, with and without an index manifest.
The serialized `Paimon::TableStateSnapshot` gained the `index_manifest` field, and the earlier commits bumped the shared `DATA_LAKE_TABLE_STATE_SNAPSHOT_PROTOCOL_VERSION` (and then wrote per-type versions) so a version 1 Paimon buffer would still decode. No such buffer exists: `serializeDataLakeTableStateSnapshot` and `deserializeDataLakeTableStateSnapshot` have no callers outside `gtest_datalake_table_state_serde.cpp`, so no build has ever written or read a Paimon state. Revert `ProtocolDefines.h`, the outer serde and the Iceberg deserializer to master, and read the index manifest as part of the version 1 Paimon layout. The unit test keeps the Paimon round trip with and without an index manifest; the per-version tests are removed with the versions. Requested in ClickHouse#122506 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ctor test Each arm now checks, right before it reads, the `(id, commit_kind)` of every snapshot (`$snapshots`) and the row count of each deletion vectors index file of the latest snapshot (`$table_indexes`): `[1]` for a live deletion vector, `[0]` for the empty file a full compaction of a bucketed table leaves, `[]` for none. The option-off arm also reads back `deletion-vectors.enabled = false`. A change in what the Spark writer produces then fails the test instead of silently changing what the read arms exercise. Expecting `[0]` instead of `[1]` in the resumed incremental arm fails it. Requested in ClickHouse#122506 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 8d080adEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261013-120004 |
|
@groeneai check CI |
|
I checked CI on 8d080ad. None of the 5 failed jobs comes from this PR:
The tests of this PR passed in every job that ran them: I cannot re-run jobs. If you want a clean run, I can merge master: it brings #125126 and re-runs the four targeted jobs. |
|
@groeneai merge master |
…-paimon-deletion-vectors Requested in ClickHouse#122506 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
The integration runner now writes the tables with Spark 4.0 and paimon-spark-4.0 1.3.2 (ClickHouse#125458) instead of paimon-spark-3.5 1.1.1. Paimon 1.3.2 commits UPDATE on an append table with deletion vectors as one OVERWRITE snapshot that carries the deletion vector, instead of an APPEND snapshot followed by a COMPACT snapshot that adds it, so every snapshot after the update moves down by one id. Update the expected layouts, refuse the targeted read of the OVERWRITE snapshot 2, and use snapshot 1, the only one without deletion vectors, as the targeted-read control. With this writer no test reached the check on skipped COMPACT snapshots any more. Add test_skipped_compaction: a partial compaction of one partition commits a COMPACT snapshot whose index manifest still lists the other partition's deletion vector, and an incremental read with its cursor just before it must refuse and keep the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged master ( 7e0be1667c7 updates the expected layouts and snapshot ids (the targeted-read control is now snapshot 1). With this writer no case reached the check on skipped On the merged build, with Spark 4.0 and Paimon 1.3.2 from the current runner image, |
CI finish ledger - 7e0be16Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
73 jobs of this run were Session id: cron:our-pr-ci-monitor:20261014-130007 |
|
Fixing PR for the targeted-job test-selection |
|
@groeneai merge master and rerun CI |
…-paimon-deletion-vectors
|
Merged master ( On the merged build locally, |
Closes: #122431
Related: #113460
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading an Apache Paimon snapshot whose index manifest lists deletion vectors now throws
NOT_IMPLEMENTEDinstead of silently returning rows that laterDELETEandUPDATEstatements removed: the reader does not apply deletion vectors. This also covers tables wheredeletion-vectors.enabledwas turned off afterwards. Closes #122431.Description
On 26.8 LTS (26.8.10.6),
paimonLocalover an append-only Paimon table with'deletion-vectors.enabled' = 'true'returns rows that a later
UPDATEorDELETEremoved. After Spark runsINSERT (1,'old'),(2,'two')andUPDATE ... SET val = 'new' WHERE id = 1, Spark reads1 new / 2 two, while ClickHouse returns1 new / 1 old / 2 two.The
paimon*table functions are ungated.Root cause. Such an update commits a snapshot (
COMPACTwith Paimon 1.1.1,OVERWRITEwith 1.3.2) whose indexmanifest holds a deletion vector for the affected data file. The reader never reads the index manifest, and #113460's guard refuses only primary-key
tables.
The change. Every snapshot a query reads is checked before its files are collected: the full-scan snapshot,
paimon_target_snapshot_id, and each snapshot an incremental read consumes, including the skippedCOMPACTones. Ifits index manifest has a non-empty
DELETION_VECTORSentry (an empty one is written when compaction removes the lastvector), the read throws
NOT_IMPLEMENTEDbefore any Keeper watermark is committed. The error names the recovery: afull compaction, or snapshot expiration or a cursor move for incremental reads. The
deletion-vectors.enabledoptionis not consulted: it can be turned off while deletion vectors stay live. The index manifest name is carried in the
pinned table state, and the file is read through the Paimon metadata cache.
Validation. The integration test
test_paimon_deletion_vectorswrites its tables at test time with Paimon Spark 1.3.2.SELECT,count(), the targeted read of snapshot 2, and resumed and fresh incrementalreads throw with the watermark kept, as does a table whose option was turned off without a full compaction. Snapshot 1
and a fully compacted table still read, and the documented cursor move resumes a blocked stream. Master fails the refusals; dropping the skipped
COMPACTcheck or theempty-entry rule fails their arms.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122506]
Version info
26.11.1.408-master(included in26.11and later)