Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug of retry #710

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading