iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Spark: WAP snapshot isolation broken for format-version 3 tables when deletion vectors are used (spark.wap.id)

Open abjain123 opened this issue 1 month ago • 5 comments

Apache Iceberg version

1.11.0

Query engine

None

Please describe the bug 🐞

When Write-Audit-Publish (WAP) is used via spark.wap.id on a format-version 3 table where deletion vectors (DVs) are in use, WAP snapshot isolation is broken in two related ways:

Failure mode 1 — WAP APPEND (INSERT): Staged data becomes visible on the main branch before cherry-pick. Reading the table from the main branch after a WAP INSERT (without cherry-picking) incorrectly returns the staged rows. Expected: main branch should not include any data from a staged WAP snapshot.

Failure mode 2 — WAP DELETE with write.delete.mode=merge-on-read: The staged WAP snapshot does not appear in .snapshots filtered by its wap.id. SELECT snapshot_id FROM
.snapshots WHERE summary['wap.id'] = '' returns 0 rows, making any subsequent cherrypick_snapshot call impossible.

Steps to Reproduce

Using any Spark + Iceberg catalog (Hadoop, Hive, REST). Verified with Spark 3.5.x + Iceberg 1.10.1.

Failure mode (WAP DELETE):

_-- Step 1: Create format-version 3 table with MOR DELETE CREATE TABLE test_wap_dv (id INT, name STRING, dept STRING) USING iceberg TBLPROPERTIES ( 'format-version' = '3', 'write.delete.mode' = 'merge-on-read' );

-- Step 2: Insert rows INSERT INTO test_wap_dv VALUES (1, 'Alice', 'Eng'), (2, 'Bob', 'HR'), (3, 'Carol', 'Eng');

-- Step 3: Enable WAP ALTER TABLE test_wap_dv SET TBLPROPERTIES ('write.wap.enabled' = 'true');

-- Step 4: Stage a DELETE under WAP SET spark.wap.id = 'wap_stage_001'; DELETE FROM test_wap_dv WHERE dept = 'HR'; -- Succeeds with no exception

-- Step 5: Find staged snapshot (BUG: returns 0 rows) SELECT snapshot_id, summary FROM test_wap_dv.snapshots WHERE summary['wap.id'] = 'wap_stage_001' ORDER BY committed_at DESC LIMIT 1; -- Expected: 1 row containing the staged snapshot ID -- Actual: 0 rows

-- Step 6: Cherry-pick fails (no snapshot ID to use) -- CALL .system.cherrypick_snapshot( -- table => '.test_wap_dv', -- snapshot_id => <id from step 5>); -- Fails with IndexError / NullPointerException because step 5 returned nothing_

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
  • [x] I cannot contribute a fix for this bug at this time

abjain123 avatar Oct 30 '26 08:10 abjain123

@abjain123 can i take this bug to work on?

akashrn5 avatar Oct 30 '26 08:10 akashrn5

Sure @akashrn5 !

abjain123 avatar Oct 30 '26 10:10 abjain123

3. Sure @akashrn5 !

Thank you, i will raise a PR in couple of days

akashrn5 avatar Oct 30 '26 11:10 akashrn5

Hey @akashrn5 , are you still working on the issue? If not then I can pick it up. Thanks!

neel429 avatar Nov 05 '26 22:11 neel429

@neel429 i was working on it, i was bit delayed due to some issues though

akashrn5 avatar Nov 09 '26 14:11 akashrn5