Retry with N1ql


Is it possible to perform retry on a N1QL query such as the below?

query = select * from bucket use keys ‘KEY’;
result = bucketObj.query(N1qlQuery.simple(query));

If yes, can anyone please give a code snippet?


The async API makes this relatively straightforward I believe, but a couple higher level questions… 1) Under what circumstances do you want to retry this? Generally it shouldn’t be necessary-- unless there’s a failure while in flight. 2) If you’re just getting the full document, perhaps you should use the .get() operation at the bucket level? That’ll be faster and more efficient.


@ingenthr… 1) I have a bucket with 300 k documents and the query mentioned above times out every now and then… Hence I want to retry the execution of the query. 2) Querying with document ID I can use .get(). But I also use N1ql with filters. I want to know if those can be retried as well.


Looks like you could be requesting a large amount of data… If the number of documents * average document size is close to the maximum size that could be handled by the systems (couchbase + network + client) in the request flow, you could get intermittent timeouts.

Additionally, if the service isn’t allocated enough memory, we see timeouts as a side effect of that condition.