Simple N1QL row iteration causes Timeout Exception

I have CB 4.5 CE. SDK 2.4.3. Single Node setup with 10G of memory. Bucket that I am querying has 1M records. All I am doing is the following (code is in Scala but Java code throws the same error too):

val params =, TimeUnit.MILLISECONDS) val query = N1qlQuery.simple("select bucketname.* from `bucketname`", params) val n1QLRowIterator = couchBucket.query(query).rows() while (n1QLRowIterator.hasNext()){ val documentID ="_id") }

I get the timeout exception as follows:

java.lang.RuntimeException: java.util.concurrent.TimeoutException at at at

P.S: No exception is thrown when buckets containing less than 100000 records are queried.

Increase timeout or don’t set. For 1M records fetch required more time. There might be otherways to get so many records using SDK. @ingenthr

@dagneytaggartsv sorry for the delay. Note that you are only tweaking the server side timeout, but not the client side one (so in your case you’ll get the client side timeout at the default 75s)… use .query(query, 100, TimeUnit.SECONDS) this will adjust the client and server side timeout to 100s, keeping them in sync. In general you never need to tune the server side timeout when using the blocking API, only with the async one.

1 Like