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

[core] Make commit.max-retries behave as it means #4641

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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 @@ -716,21 +716,10 @@ private int tryCommit(
ConflictCheck conflictCheck,
String branchName,
@Nullable String statsFileName) {
int cnt = 0;
int retryCount = 0;
RetryResult retryResult = null;
while (true) {
Snapshot latestSnapshot = snapshotManager.latestSnapshot();
cnt++;
if (cnt >= commitMaxRetries) {
if (retryResult != null) {
retryResult.cleanAll();
}
throw new RuntimeException(
String.format(
"Commit failed after %s attempts, there maybe exist commit conflicts between multiple jobs.",
commitMaxRetries));
}

CommitResult result =
tryCommitOnce(
retryResult,
Expand All @@ -751,8 +740,19 @@ private int tryCommit(
}

retryResult = (RetryResult) result;

if (retryCount >= commitMaxRetries) {
if (retryResult != null) {
retryResult.cleanAll();
}
throw new RuntimeException(
String.format(
"Commit failed after %s retries, there maybe exist commit conflicts between multiple jobs.",
commitMaxRetries));
}
retryCount++;
}
return cnt;
return retryCount + 1;
}

private int tryOverwrite(
Expand All @@ -762,17 +762,10 @@ private int tryOverwrite(
long identifier,
@Nullable Long watermark,
Map<Integer, Long> logOffsets) {
int cnt = 0;
int retryCount = 0;
while (true) {
Snapshot latestSnapshot = snapshotManager.latestSnapshot();

cnt++;
if (cnt >= commitMaxRetries) {
throw new RuntimeException(
String.format(
"Commit failed after %s attempts, there maybe exist commit conflicts between multiple jobs.",
commitMaxRetries));
}
List<ManifestEntry> changesWithOverwrite = new ArrayList<>();
List<IndexManifestEntry> indexChangesWithOverwrite = new ArrayList<>();
if (latestSnapshot != null) {
Expand Down Expand Up @@ -828,8 +821,16 @@ private int tryOverwrite(
// TODO optimize OVERWRITE too
RetryResult retryResult = (RetryResult) result;
retryResult.cleanAll();

if (retryCount >= commitMaxRetries) {
throw new RuntimeException(
String.format(
"Commit failed after %s retries, there maybe exist commit conflicts between multiple jobs.",
commitMaxRetries));
}
retryCount++;
}
return cnt;
return retryCount + 1;
}

@VisibleForTesting
Expand Down Expand Up @@ -1069,22 +1070,22 @@ CommitResult tryCommitOnce(
}

public void compactManifest() {
int cnt = 0;
int retryCount = 0;
ManifestCompactResult retryResult = null;
while (true) {
cnt++;
retryResult = compactManifest(retryResult);
if (retryResult.isSuccess()) {
break;
}

if (cnt >= commitMaxRetries) {
if (retryCount >= commitMaxRetries) {
retryResult.cleanAll();
throw new RuntimeException(
String.format(
"Commit compact manifest failed after %s attempts, there maybe exist commit conflicts between multiple jobs.",
"Commit compact manifest failed after %s retries, there maybe exist commit conflicts between multiple jobs.",
commitMaxRetries));
}
retryCount++;
}
}

Expand Down
Loading