Time out Exception


we are receiving below error while trying to use upsert method. we are using upsert in a loop with 10 threards.

java.lang.RuntimeException: java.util.concurrent.TimeoutException
at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:93)
at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:262)
at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:257)


Is there anyway to speed up inserts like bulk or batch process?

Here is upsert code.

	bucket = cluster.openBucket(databaseName, "");
	JsonDocument document = JsonDocument.create(id, jsonObject);


Hi @gadipati,

a timeout can happen for lots and lots of reasons. In order to pinpoint what’s going on, we need more information. Let’s start with:

  • Can you show us more logs in the surrounding context (if not too much load is going on)?
  • What ind of workload are you running?
  • How is your cluster setup?
  • Are you receiving timeouts all the time or just sometimes?

Also, you want to make sure to not open the bucket every time you do an operation (just in case). You can also read more on bulk processing in our documentation: http://docs.couchbase.com/developer/java-2.1/documents-bulk.html

I am also getting this logs regularly while upserting the documents using Bucket.

message=java.util.concurrent.TimeoutException java.lang.RuntimeException: java.util.concurrent.TimeoutException
27572- at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:93) ~[com.couchbase.client.java-client-2.1.4.jar:2.1.4]
27573- at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:268) ~[com.couchbase.client.java-client-2.1.4.jar:2.1.4]
27574- at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:263) ~[com.couchbase.client.java-client-2.1.4.jar:2.1.4]

It’s not usually helpful to pick up an old forum posting based on the same error message. Timeouts are not a bug, it’s an indication that something is not well set up in the environment.

That’s indicative of some kind of resource exhaustion in most cases. Is the network good between the client and server? Should be LAN like throughputs and latencies. Are the systems reasonable CPU/network (i.e., not Amazon EC2 micro if you’re trying to run high throughput low latency tests)

Couchbase we have installed on c4 extra large instance, and the application on c4 large. But when we build the application, sometimes the connection becomes unstable , which leads to timeout exception whenever we get or set the data in the couchbase bucket.

Are the app servers and database servers in the same region?

Another possible cause could be something in the application logic using asynchronous operations. Note that an async operation is effectively a memory allocation and if you do a lot at once, you can easily saturate the network leading to timeouts. We frequently see this with ‘dumb benchmarks’.

Can you help us help you by creating a new forums topic that really addresses what you’re trying to do, what the environment looks like, and what you’re seeing?