Core: Deleted rows reappear and filtered writes miss rows when binary or fixed partition summaries were written before 1.11.0
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #19056 @karubian による — マージされずにクローズ
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
調査の方向性
Start with ManifestEvaluator, ManifestFileUtil.canContainAny, and the linked scan-planning call sites; the issue names these as places that trust manifest partition bounds. Compare each manifest's partition summary with its live entries, using the SQL query in the issue as a diagnostic starting point. Determine whether the repair belongs in RepairTable or rewrite_manifests, then verify repaired summaries cover their entries and filtered reads and writes preserve deleted rows.
索引モデルが issue の本文から書いたものです。
説明
Apache Iceberg version
1.12.0 (latest release)
Query engine
Spark
Please describe the bug 🐞
On a table partitioned by a binary or fixed column, Iceberg Java before 1.11.0 can write a manifest list partition summary whose bounds leave out the manifest's own partition values, #15128. #15127 fixed new writes in 1.11.0, but a snapshot keeps a manifest and its summary until a commit rewrites that manifest, and current releases still skip manifests by those bounds. #15128 shows a filtered read missing rows. On a delete manifest, a filtered scan plans the data file without its deletes, so deleted rows come back, and a filtered write can make that permanent.
On Spark 3.5.3 with a Hadoop catalog, the setup on Iceberg 1.10.1, then the session restarted on 1.12.0 on the same warehouse:
-- Iceberg 1.10.1
CREATE TABLE t (id bigint NOT NULL, data binary) USING iceberg PARTITIONED BY (data)
TBLPROPERTIES ('format-version' = '2', 'write.delete.mode' = 'merge-on-read');
INSERT INTO t VALUES (1, X'e3bcd1'), (2, X'e3bcd1');
INSERT INTO t VALUES (3, X'bcd1'), (4, X'bcd1');
DELETE FROM t WHERE id IN (1, 3); -- one delete manifest, summary [bcd1, e3bcd1]
DELETE FROM t WHERE data = X'bcd1'; -- a metadata delete rewrites it, summary [bcd1, bcd1d1]
-- Iceberg 1.12.0, same warehouse
SELECT id FROM t; -- 2
SELECT id FROM t WHERE data = X'e3bcd1'; -- 1, 2
UPDATE t SET id = id + 100 WHERE data = X'e3bcd1' AND id = 2; -- copy-on-write
SELECT id FROM t; -- 1, 102
The update's scan did not apply the delete, so it copied row 1 into the new data file, and row 1 is back for every reader; the commit then drops the delete as older than every live data file. With the setup on 1.12.0 every statement gives the right rows; a build of main, 2bd60a0, gives the same results as 1.12.0. Also on 1.12.0:
- On this table, a copy-on-write
DELETEorMERGEwith a condition ondataandrewrite_data_fileswithwhere => "data = X'e3bcd1'"andoptions => map('rewrite-all', 'true')bring row 1 back too, and a merge-on-readUPDATEwrites it back as row 101. An unfilteredrewrite_data_fileswithrewrite-allapplies the delete. - On the same table in format version 3, where 1.10.1 wrote the wrong summary in about half the runs, by the order of the deletion vectors in the manifest, the filtered read returns row 1, the filtered
rewrite_data_filesand copy-on-writeUPDATE,DELETEandMERGEbring it back, and a merge-on-readUPDATE,DELETEorMERGEadds a second deletion vector for the data file, after which unfiltered reads andrewrite_data_filesfail withCan't index multiple DVs, the state of #17206, reached here by one write with no concurrent writer. - In the data manifest shape of #15128, a filtered
DELETEorUPDATEsucceeds and changes nothing,MERGE ... WHEN NOT MATCHED THEN INSERTadds a duplicate row, andwriteTo(t).overwrite(...)or a dynamicINSERT OVERWRITEof the partition keeps the old rows. - PyIceberg 0.12.0 reads the v2 table and the data manifest table the same wrong way: the summaries are wrong for every reader that prunes by them.
Which tables: every release tested from 1.4.3 to 1.10.2 wrote such summaries for binary partitions, and 1.9.2 to 1.10.2 for fixed ones; on earlier releases the test could not commit a fixed partition value. String and uuid partitions, tested as controls, kept right summaries. A recorded bound takes the bytes of the next entry read when that value is no longer, so whether a summary goes wrong depends on the order and lengths of the values. Any commit that copies entries into a new manifest can write one: a metadata delete, an overwrite, a commit that removes files, or a manifest merge, which appends and row deltas do once a table has enough manifests. The partition fields at risk are identity on a binary or fixed column and truncate on a binary column; bucket on a binary column has int bounds and is not affected.
The summaries alone cannot tell a wrong bound from a right one; the entries can. This lists the live entries outside their manifest's bounds for a table whose first partition field is the binary one:
SET spark.sql.optimizer.nestedSchemaPruning.enabled = false; -- the manifests table cannot project one summary field
SELECT m.content, base64(e.data_file.partition.data) AS value,
m.partition_summaries[0].lower_bound AS lower, m.partition_summaries[0].upper_bound AS upper
FROM (SELECT input_file_name() AS manifest, status, data_file FROM t.entries) e
JOIN t.manifests m ON e.manifest = m.path
WHERE e.status < 2
AND (e.data_file.partition.data < unbase64(m.partition_summaries[0].lower_bound)
OR e.data_file.partition.data > unbase64(m.partition_summaries[0].upper_bound));
It flags the v2, v3 and data manifest tables written on 1.10.1, and none written on 1.12.0. It must not filter on the partition column, since metadata tables prune by the same summaries.
Where Iceberg Java trusts the bounds, which Manifest Lists requires to cover the manifest's values and Scan Planning lets readers skip by:
ManifestEvaluator, behind scan planning of data and delete manifests, DeleteFileIndex and BaseDistributedDataScan, metadata tables including thedata_fileslookup of #19035, row filter deletes and conflict validation.- ManifestFileUtil.canContainAny, behind partition drops and deletes of files that do not name their manifest, ManifestFilterManager.
Repair today, on 1.11.0 or later: rewrite_manifests writes right summaries for the manifests it rewrites, within the chosen spec. It skips a manifest that is the only one of its content when the target size asks for one manifest, RewriteManifestsSparkAction, as in this table. With writers paused, one run with commit.manifest.target-size-bytes set one byte below the smallest manifest's length rewrote the lone manifests of the v2 and data manifest tables with right summaries; then restore the property, since every commit reads it, and run rewrite_manifests again to merge what the first run split. The target applies to every content, so on a table whose manifests differ widely in size the first run can split the larger content into many manifests until the second run. The core RewriteManifests keeps delete manifests in its clustering rewrite. Repairing summaries cannot undo an incorrect data rewrite or restore deletes removed by its commit, and a v3 table with two deletion vectors for one data file needs a rollback.
I'd propose two changes that keep manifest pruning on healthy tables. rewrite_position_delete_files should look up the live data files of a partition without filtering on binary and fixed partition fields, since it drops the deletes of a live data file without any filter on the partition column, #19035; #19036 does this for binary and fixed fields. And a repair should check each manifest's partition summary against its entries, rewrite the manifests whose summary leaves out their values, and report them. It could be a mode of the RepairTable action from #17399, whose Spark implementation in #17622 repairs only file metrics, or a rewrite_manifests option that rewrites every manifest of each spec and content. A repair gives every reader, PyIceberg included, right summaries from the snapshot it commits, as long as the table's writers are on 1.11.0 or later; after the run above, the filtered read on 1.12.0 returned the right row. Until a table is repaired, filtered scans and writes on it keep the wrong results above; engines that plan with Iceberg Java, such as Flink and Trino, and equality deletes go through the same code, though they were not run here. Stopping ManifestEvaluator and ManifestFileUtil.canContainAny from comparing values with binary and fixed bounds fixes every case above, but drops manifest pruning on those fields for every table, healthy ones too, so I closed #19056. Would RepairTable or rewrite_manifests be the better home for the repair?
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
- 主要言語
- Java
- スター
- 9.4k
- フォーク
- 3.7k
- 平均マージ
- 2日 15時間
- マージ済み PR(30日)
- 169
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg のほかの issue
-
Spark: Test INSERT targets with computed IDENTIFIER expressions対応中かも @shivadarshan-devadiga が 8 日前に担当しました。 オープンimprovement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scan対応中かも @Ankitkj1999 が 10 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Flink: JdbcLockFactory concurrent lock-table creation can fail with "table already exists" and restart the job対応中かも @adiranjan25 が 17 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/iceberg#18797 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tables対応中かも @yusufyildiz34 が 29 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/iceberg#18632 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToList対応中かも @mohamed-elbrik が 34 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
hermes-queue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
chrisalunlloyd2-sudo/mindpalace#430 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
unitycatalog/unitycatalog#2363 ·
メンテナーはふだん 1 日以内に返信
-
area: editor P3 type: feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
halisonworks/mod-codeling#290 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
area/dependencies area/dependencies/js backport/26.6 backport/26.8 kind/cve severity/medium source/scan-dependencies status/triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 2 日以内に返信