Skip to content

Commit

Permalink
[To rc/1.3.3][Inconsistent copies] Enhance IoTConsensus Retry (#13431)
Browse files Browse the repository at this point in the history
  • Loading branch information
HxpSerein authored Sep 6, 2024
1 parent fb12fbf commit 1df0000
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ public void onComplete(TSyncLogEntriesRes response) {
messages);
sleepCorrespondingTimeAndRetryAsynchronous();
} else {
if (logger.isDebugEnabled()) {
boolean containsError =
response.getStatuses().stream()
.anyMatch(
status -> status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode());
if (containsError) {
logger.debug(
"Send {} to peer {} complete but contains unsuccessful status: {}",
batch,
thread.getPeer(),
response.getStatuses());
}
}
completeBatch(batch);
}
logDispatcherThreadMetrics.recordSyncLogTimePerRequest(System.nanoTime() - createTime);
Expand All @@ -88,21 +101,19 @@ public static boolean needRetry(int statusCode) {
@Override
public void onError(Exception exception) {
++retryCount;
if (logger.isWarnEnabled()) {
Throwable rootCause = ExceptionUtils.getRootCause(exception);
logger.warn(
"Can not send {} to peer for {} times {} because {}",
batch,
thread.getPeer(),
retryCount,
rootCause.toString());
// skip TApplicationException caused by follower
if (rootCause instanceof TApplicationException) {
completeBatch(batch);
logger.warn("Skip retrying this Batch {} because of TApplicationException.", batch);
logDispatcherThreadMetrics.recordSyncLogTimePerRequest(System.nanoTime() - createTime);
return;
}
Throwable rootCause = ExceptionUtils.getRootCause(exception);
logger.warn(
"Can not send {} to peer for {} times {} because {}",
batch,
thread.getPeer(),
retryCount,
rootCause.toString());
// skip TApplicationException caused by follower
if (rootCause instanceof TApplicationException) {
completeBatch(batch);
logger.warn("Skip retrying this Batch {} because of TApplicationException.", batch);
logDispatcherThreadMetrics.recordSyncLogTimePerRequest(System.nanoTime() - createTime);
return;
}
sleepCorrespondingTimeAndRetryAsynchronous();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,7 @@ private File getSnapshotLogFile() {
if (sourceDataDir.exists()) {
File[] files =
sourceDataDir.listFiles((dir, name) -> name.equals(SnapshotLogger.SNAPSHOT_LOG_NAME));
if (files == null || files.length == 0) {
LOGGER.warn("Failed to find snapshot log file, cannot recover it");
} else if (files.length > 1) {
LOGGER.warn(
"Found more than one snapshot log file, cannot recover it. {}", Arrays.toString(files));
} else {
if (files != null && files.length == 1) {
LOGGER.info("Reading snapshot log file {}", files[0]);
return files[0];
}
Expand Down

0 comments on commit 1df0000

Please sign in to comment.