Skip to content

[core][flink] Detect overwrite conflicts for index commits#7972

Open
leaves12138 wants to merge 6 commits into
apache:masterfrom
leaves12138:codex/row-id-reassign-conflict
Open

[core][flink] Detect overwrite conflicts for index commits#7972
leaves12138 wants to merge 6 commits into
apache:masterfrom
leaves12138:codex/row-id-reassign-conflict

Conversation

@leaves12138
Copy link
Copy Markdown
Contributor

@leaves12138 leaves12138 commented May 26, 2026

Purpose

Prevent stale row-id-sensitive global index commits after later OVERWRITE snapshots change row-id/index safety.

Changes

  • Add overwrite conflict checking via commit.overwrite-conflict.last-safe-snapshot.
  • Mark row-id reassignment snapshots with the transient overwrite-barrier snapshot property.
  • Abort index commits when a later overwrite barrier snapshot exists, or when a later ordinary overwrite snapshot touches the target partitions.
  • Wire Flink btree/generic global index commits to pass the scan snapshot through dynamic commit options.
  • Keep the transient overwrite barrier property out of normal manifest rewrite and compact snapshots.
  • Add tests for overwrite barrier detection, overlapped overwrite detection, barrier property cleanup, and row-id reassignment metadata.

Validation

  • git diff --check
  • mvn -pl paimon-flink/paimon-flink-common -am -Pfast-build -DskipTests compile
  • mvn -pl paimon-spark/paimon-spark-common -am -Pfast-build -DskipTests compile
  • mvn -pl paimon-core -am -Pfast-build -DfailIfNoTests=false -Dtest=ConflictDetectionTest#testDetectsOverwriteBarrierSnapshotConflict+testIgnoresOverwriteBarrierPropertyOnNonOverwriteSnapshot+testDetectsOverlappedOverwriteSnapshotForIndexCommit+testIgnoresNonOverlappedOverwriteSnapshotForIndexCommit test was attempted locally, but this environment fails during paimon-core test compilation because the existing shaded Parquet test dependency is unavailable (org.apache.paimon.shade.org.apache.parquet.hadoop).
  • GitHub Actions currently fail during checkout with remote: Your account is suspended / HTTP 403, before project build/test execution.

@leaves12138 leaves12138 force-pushed the codex/row-id-reassign-conflict branch 3 times, most recently from 8ddb1ea to cd070af Compare May 26, 2026 07:52
@leaves12138 leaves12138 marked this pull request as ready for review May 26, 2026 08:14
@leaves12138 leaves12138 force-pushed the codex/row-id-reassign-conflict branch from cd070af to a271615 Compare May 26, 2026 08:33
@leaves12138 leaves12138 marked this pull request as draft May 26, 2026 08:34
@leaves12138 leaves12138 marked this pull request as ready for review May 26, 2026 08:39
return rowIdCheckFromSnapshot != null;
}

public void setRowIdReassignCheckFromSnapshot(@Nullable Long rowIdReassignCheckFromSnapshot) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just reuse setRowIdCheckFromSnapshot?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I think these two snapshot markers should stay separate because they guard different invariants. rowIdCheckFromSnapshot is used by row-id range / column-level conflict checks, while this one is driven by commit.row-id-reassign.last-safe-snapshot and scans later OVERWRITE snapshots for row-id reassign or overlapped partition overwrite conflicts during index build/compact commits. Reusing the existing field would couple two independent checks and make the COMPACT/index path harder to reason about.

Copy link
Copy Markdown
Contributor

@jerry-024 jerry-024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Three minor optimization suggestions below — none are blockers.

Long rowIdReassignCheckFromSnapshot =
indexBuilder.scanSnapshotId().isPresent()
? indexBuilder.scanSnapshotId().get()
: null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can be simplified to:

Long rowIdReassignCheckFromSnapshot = indexBuilder.scanSnapshotId().orElse(null);

Optional.orElse(null) is idiomatic and avoids the double method call.

CoreOptions.COMMIT_ROW_ID_REASSIGN_LAST_SAFE_SNAPSHOT.key(),
String.valueOf(rowIdReassignCheckFromSnapshot)));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This method is identical to BTreeIndexTopoBuilder.withRowIdReassignCheck. Consider extracting to a shared utility to avoid drift if the option key or logic changes later. Not blocking — the method is small.

}

@Test
public void testRowIdReassignConflictFromOptions() throws Exception {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a test that verifies compactManifestOnce also strips ROW_ID_REASSIGN_PROPERTY. Current tests cover replaceManifestList but not the compact path.

@leaves12138 leaves12138 changed the title [core][flink] Detect row-id reassign conflicts for index commits [core][flink] Detect row-id overwrite conflicts for index commits May 26, 2026
@leaves12138 leaves12138 changed the title [core][flink] Detect row-id overwrite conflicts for index commits [core][flink] Detect overwrite conflicts for index commits May 26, 2026
@leaves12138 leaves12138 force-pushed the codex/row-id-reassign-conflict branch from fa46435 to 923532c Compare May 26, 2026 10:26
@leaves12138 leaves12138 marked this pull request as draft May 26, 2026 11:12
@leaves12138 leaves12138 marked this pull request as ready for review May 26, 2026 11:12
@leaves12138 leaves12138 reopened this May 26, 2026
@leaves12138 leaves12138 reopened this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants