Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyu committed Dec 10, 2024
1 parent 416a2d0 commit 38b13c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1935,8 +1935,8 @@ public boolean commitForceCompact() {
return options.get(COMMIT_FORCE_COMPACT);
}

public Optional<Duration> commitMaxTimeout() {
return options.getOptional(COMMIT_MAX_TIMEOUT);
public Duration commitMaxTimeout() {
return options.get(COMMIT_MAX_TIMEOUT);
}

public int commitMaxRetries() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class FileStoreCommitImpl implements FileStoreCommit {
private final List<CommitCallback> commitCallbacks;
private final StatsFileHandler statsFileHandler;
private final BucketMode bucketMode;
private final Optional<Duration> commitMaxTimeout;
@Nullable private Duration commitMaxTimeout;
private final int commitMaxRetries;

@Nullable private Lock lock;
Expand Down Expand Up @@ -169,7 +169,7 @@ public FileStoreCommitImpl(
@Nullable Integer manifestReadParallelism,
List<CommitCallback> commitCallbacks,
int commitMaxRetries,
Optional<Duration> commitMaxTimeout) {
@Nullable Duration commitMaxTimeout) {
this.fileIO = fileIO;
this.schemaManager = schemaManager;
this.tableName = tableName;
Expand Down Expand Up @@ -750,24 +750,17 @@ private int tryCommit(
}

retryResult = (RetryResult) result;

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

if (commitMaxTimeout.isPresent()
&& System.currentTimeMillis() - startMillis
> commitMaxTimeout.get().toMillis()) {
if ((commitMaxTimeout != null
&& System.currentTimeMillis() - startMillis
> commitMaxTimeout.toMillis())
|| retryCount >= commitMaxRetries) {
retryResult.cleanAll();
throw new RuntimeException(
String.format(
"Commit failed after %s millis, there maybe exist commit conflicts between multiple jobs.",
commitMaxTimeout.get().toMillis()));
"Commit failed after %s millis with %s retries, there maybe exist commit conflicts between multiple jobs.",
commitMaxTimeout.toMillis(), retryCount));
}
}
return retryCount + 1;
Expand Down Expand Up @@ -1074,23 +1067,17 @@ public void compactManifest() {
break;
}

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

if (commitMaxTimeout.isPresent()
&& System.currentTimeMillis() - startMillis
> commitMaxTimeout.get().toMillis()) {
if ((commitMaxTimeout != null
&& System.currentTimeMillis() - startMillis
> commitMaxTimeout.toMillis())
|| retryCount >= commitMaxRetries) {
retryResult.cleanAll();
throw new RuntimeException(
String.format(
"Commit failed after %s millis, there maybe exist commit conflicts between multiple jobs.",
commitMaxTimeout.get().toMillis()));
"Commit failed after %s millis with %s retries, there maybe exist commit conflicts between multiple jobs.",
commitMaxTimeout.toMillis(), retryCount));
}
}
}
Expand Down

0 comments on commit 38b13c7

Please sign in to comment.