In my application I am initializing the all buckets on application startup as in below code
List<String> bucketList = Arrays.asList("Bucket1", "Bucket2", "Bucket3");
long totalTime = 0L;
for (String bucketName : bucketList) {
try {
long startTime = System.currentTimeMillis();
bucket = cluster.bucket(bucketName);
// get a collection reference
Collection collection = bucket.defaultCollection();
bucket.waitUntilReady(Duration.ofSeconds(10));
collectionMap.put(bucketName, collection);
long timeTaken = System.currentTimeMillis() - startTime;
totalTime += timeTaken;
System.out.println("## Time taken to initialized the bucket:" + bucketName + " = " + timeTaken);
} catch (Exception e) {
System.out.println(">>>>>>>>>>>Exception in initialization : " + e);
}
}
Here bucket.waitUntilReady
is causing the issue when any bucket not present in Couchbase server from list
i.e in above code if ‘Bucket2’ is not present then it throw the exception com.couchbase.client.core.error.UnambiguousTimeoutException: WaitUntilReady timed out
for Bucket2
Due to Bucket2
does not exist in Couchbase, in next iteration of loop when try to initialized Bucket3
(which available) also throw com.couchbase.client.core.error.UnambiguousTimeoutException: WaitUntilReady timed out
even bucket is available due to bucket.waitUntilReady
.
It keep attempting to connect to Bucket2
continuous even after timeout in bucket.waitUntilReady(Duration.ofSeconds(10)); as below
WARNING: [com.couchbase.endpoint][EndpointConnectionFailedEvent][190ms] Connect attempt 12 failed because of AuthenticationFailureException: Either the bucket with name “Bucket2” is not present or the user does not have the right privileges to access it {“bucket”:“Bucket2”,“circuitBreaker”:“DISABLED”,“coreId”:“0xe38db72200000001”,“remote”:“10.60.32.61:11210”,“status”:“NO_ACCESS”,“type”:“KV”} {“bucket”:“Bucket2”,“circuitBreaker”:“DISABLED”,“coreId”:“0xe38db72200000001”,“remote”:“10.60.32.61:11210”,“type”:“KV”}
com.couchbase.client.core.error.AuthenticationFailureException: Either the bucket with name “Bucket2” is not present or the user does not have the right privileges to access it {“bucket”:“Bucket2”,“circuitBreaker”:“DISABLED”,“coreId”:“0xe38db72200000001”,“remote”:“10.60.32.61:11210”,“status”:“NO_ACCESS”,“type”:“KV”}
at com.couchbase.client.core.io.netty.kv.SelectBucketHandler.channelRead(SelectBucketHandler.java:172)
at com.couchbase.client.core.io.netty.kv.MemcacheProtocolVerificationHandler.channelRead(MemcacheProtocolVerificationHandler.java:85)
at java.lang.Thread.run(Thread.java:748)
Could you please help how to stop attempting in case of bucket is not available on Couchbase server