Skip to content

Commit

Permalink
Fix a retry bug (#829)
Browse files Browse the repository at this point in the history
Signed-off-by: yhmo <[email protected]>
  • Loading branch information
yhmo authored Mar 29, 2024
1 parent 415e8b8 commit 9439a12
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main/java/io/milvus/client/MilvusServiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,18 @@ private <T> R<T> retry(Callable<R<T>> callable) {
return resp;
}

// print log, follow the pymilvus logic
if (k > 3) {
logWarning(String.format("Retry(%d) with interval %dms. Reason: %s",
k, retryIntervalMs, e.getMessage()));
}

// sleep for interval
if (k != maxRetryTimes) {
if (k >= maxRetryTimes) {
// finish retry loop, return the response of the last retry
String msg = String.format("Finish %d retry times, stop retry", maxRetryTimes);
logError(msg);
return resp;
} else {
// sleep for interval
// print log, follow the pymilvus logic
if (k > 3) {
logWarning(String.format("Retry(%d) with interval %dms. Reason: %s",
k, retryIntervalMs, e.getMessage()));
}
TimeUnit.MILLISECONDS.sleep(retryIntervalMs);
}

Expand Down

0 comments on commit 9439a12

Please sign in to comment.