Skip to content

Commit

Permalink
Fix a bug of retry (#710)
Browse files Browse the repository at this point in the history
Signed-off-by: yhmo <[email protected]>
  • Loading branch information
yhmo authored Dec 13, 2023
1 parent 8af19c2 commit 11b00a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions examples/main/java/io/milvus/GeneralExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.alibaba.fastjson.JSONObject;
import com.google.protobuf.ByteString;
import io.milvus.client.MilvusClient;
import io.milvus.client.MilvusServiceClient;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.common.utils.JacksonUtils;
Expand All @@ -44,15 +45,18 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////

public class GeneralExample {
private static final MilvusServiceClient milvusClient;
private static final MilvusClient milvusClient;

static {
ConnectParam connectParam = ConnectParam.newBuilder()
.withHost("localhost")
.withPort(19530)
.withAuthorization("root","Milvus")
.build();
milvusClient = new MilvusServiceClient(connectParam);
RetryParam retryParam = RetryParam.newBuilder()
.withMaxRetryTimes(3)
.build();
milvusClient = new MilvusServiceClient(connectParam).withRetry(retryParam);
}

private static final String COLLECTION_NAME = "java_sdk_example_general";
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/milvus/client/MilvusServiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,10 @@ private <T> R<T> retry(Callable<R<T>> callable) {

// for server-side returned error, only retry for rate limit
// in new error codes of v2.3, rate limit error value is 8
if (!(serverException.getCompatibleCode() == ErrorCode.RateLimit
|| serverException.getStatus() == 8)) {
if (retryParam.isRetryOnRateLimie() &&
(serverException.getCompatibleCode() == ErrorCode.RateLimit ||
serverException.getStatus() == 8)) {
} else {
return resp;
}
} else {
Expand Down

0 comments on commit 11b00a1

Please sign in to comment.