N1QL query execution from SpringBoot Java


In our project we are using spring boot and couchbase library to interact between application and couchbase.

Now we are facing an intermittent issue as follows…

we have written a scheduler which after some configurable amount of time executes a N1QL query using couchbase library.

Our code is something like this…

import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.query.N1qlQuery;
import com.couchbase.client.java.query.N1qlParams;
import com.couchbase.client.java.query.consistency.ScanConsistency;

final Bucket couchbaseBucket = getCouchbaseBucket();
final N1qlQueryResult result = couchbaseBucket.query(N1qlQuery.simple(query, N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED)));

if (!SUCCESS.equals(result.status())) {
	throw new RuntimeException("Exception due to non SUCCESS status");

the query variable written above is containing a simple select query need to be executed in couchbase

Now after configurable amount of time when the above lines of code getting executed then sometimes from couchbase side status is not getting returned as SUCCESS.

So can you please help me to understand what are the statuses I can expect during the above code execution and at the same time due to what reason that statuses can come instead of SUCCESS and how to ensure always SUCCESS status come in response of N1QL query execution?

Please let me know if further details required to be provided from my side regarding the same.