Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark 3.5: Fix RewriteDataFiles with partial progress enabled and max-failed-commits larger than total-file-group #12120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ private Builder doExecuteWithPartialProgress(
// stop commit service
commitService.close();

int failedCommits = maxCommits - commitService.succeededCommits();
int totalCommits = groupsPerCommit == 1 ? ctx.totalGroupCount() : maxCommits;
int failedCommits = totalCommits - commitService.succeededCommits();
if (failedCommits > 0 && failedCommits <= maxFailedCommits) {
LOG.warn(
"{} is true but {} rewrite commits failed. Check the logs to determine why the individual "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,33 @@ public void testParallelPartialProgressWithMaxFailedCommits() {
shouldHaveACleanCache(table);
}

@TestTemplate
public void testParallelPartialProgressWithMaxFailedCommitsLargerThanTotalFileGroup() {
Table table = createTable(20);
int fileSize = averageFileSize(table);

List<Object[]> originalData = currentData();

RewriteDataFilesSparkAction rewrite =
basicRewrite(table)
.option(
RewriteDataFiles.MAX_FILE_GROUP_SIZE_BYTES, Integer.toString(fileSize * 2 + 1000))
.option(RewriteDataFiles.MAX_CONCURRENT_FILE_GROUP_REWRITES, "3")
.option(RewriteDataFiles.PARTIAL_PROGRESS_ENABLED, "true")
.option(RewriteDataFiles.PARTIAL_PROGRESS_MAX_COMMITS, "20")
.option(RewriteDataFiles.PARTIAL_PROGRESS_MAX_FAILED_COMMITS, "0");
rewrite.execute();

table.refresh();

List<Object[]> postRewriteData = currentData();
assertEquals("We shouldn't have changed the data", originalData, postRewriteData);
// With 10 original groups and max commits of 20, we have 1 group per commit.
shouldHaveSnapshots(table, 11);
shouldHaveNoOrphans(table);
shouldHaveACleanCache(table);
}

@TestTemplate
public void testInvalidOptions() {
Table table = createTable(20);
Expand Down