Skip to content

[core] Refactor sort compact to produce COMPACT commits#8571

Open
hbgstc123 wants to merge 4 commits into
apache:masterfrom
hbgstc123:fix_sort_compact
Open

[core] Refactor sort compact to produce COMPACT commits#8571
hbgstc123 wants to merge 4 commits into
apache:masterfrom
hbgstc123:fix_sort_compact

Conversation

@hbgstc123

Copy link
Copy Markdown

Purpose

Follow up on #7595 per this review comment: sort compact should not be modeled as an OVERWRITE commit with extra base-snapshot handling. Instead, it should produce a normal COMPACT commit so the existing commit protocol can perform compact validation and conflict detection.

This PR fixes the concurrent-write data loss risk in sort compact by refactoring Flink/Spark sort compact to:

  1. Write sorted output in write-only mode.
  2. Rewrite the written append commit messages into CompactIncrement messages.
  3. Commit them through the normal compact commit path.

No new overwritePartition(baseSnapshotId) APIs or special overwrite conflict logic are introduced.

Tests

Core

  • SortCompactCommitMessageRewriterTest
    • rewrite to compact messages
    • multi-bucket / cross-bucket rewrite
    • deletion-vector cleanup
    • hash-dynamic hash-index cleanup
    • snapshot sequence range preservation
    • inline compaction rejection
    • compact commit success detection, including expired snapshot gaps
  • ConflictDetectionTest
  • KeyValueTableReadSequenceTest
  • IncrementalDiffSplitReadTest
  • PrimaryKeyTableRawFileSplitReadProviderTest

Flink

  • SortCompactCommitterTest
  • SortCompactSinkWriteTest
  • SortCompactActionForAppendTableITCase
    • latest snapshot kind is COMPACT
    • concurrent append between read and commit does not lose data
  • SortCompactActionForDynamicBucketITCase
  • CommitterOperatorTest
  • FlinkSourceBuilderTest

Spark

  • SortCompactSparkCommitTest
  • CompactProcedureTestBase updated to expect COMPACT

@hbgstc123 hbgstc123 force-pushed the fix_sort_compact branch 2 times, most recently from 17267f4 to 17d1a07 Compare July 12, 2026 10:40
hbg and others added 2 commits July 12, 2026 20:41
Co-authored-by: Cursor <cursoragent@cursor.com>
Pass the real table schema into KeyValueTableRead in test helpers so
keyValueSequenceNumberEnabled() can read schema options without NPE.

Co-authored-by: Cursor <cursoragent@cursor.com>
hbg and others added 2 commits July 12, 2026 22:08
Only emit delete-only compact commits at job end, use restore-only
state for dynamic-bucket sort compact, and compact test data before
checking raw-convertible splits.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant