From 9439a12cca4c0cb29a64fea0d35c1d07dcba760c Mon Sep 17 00:00:00 2001 From: groot Date: Fri, 29 Mar 2024 11:49:07 +0800 Subject: [PATCH] Fix a retry bug (#829) Signed-off-by: yhmo --- .../io/milvus/client/MilvusServiceClient.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/milvus/client/MilvusServiceClient.java b/src/main/java/io/milvus/client/MilvusServiceClient.java index c763e6dfc..286dcb942 100644 --- a/src/main/java/io/milvus/client/MilvusServiceClient.java +++ b/src/main/java/io/milvus/client/MilvusServiceClient.java @@ -328,14 +328,18 @@ private R retry(Callable> 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); }