Timeout when running DELETE query

I run integration tests backed by Couchbase Community Edition 4.1.1 and sometimes a couple of tests fails because of java.util.concurrent.TimeoutException.
The error appears when running "DELETE FROM " + bucket; with REQUEST_PLUS consistency.
I’m using Spring Data Couchbase for communication with Couchbase.
The couchbase java client version is 2.2.8
N1QL timeout is set to 7,5 seconds.

Here is a Java code:

String statement = "DELETE FROM " + bucket + " USE KEYS $1";
couchbaseTemplate.queryN1QL(parameterized(statement, from(), build().consistency(REQUEST_PLUS)));

and the end part of the exception:

Caused by: java.lang.RuntimeException: java.util.concurrent.TimeoutException
        at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:75) ~[java-client-2.2.8.jar:na]
	at com.couchbase.client.java.CouchbaseBucket.query(CouchbaseBucket.java:656) ~[java-client-2.2.8.jar:na]
	at com.couchbase.client.java.CouchbaseBucket.query(CouchbaseBucket.java:582) ~[java-client-2.2.8.jar:na]
	at org.springframework.data.couchbase.core.CouchbaseTemplate$8.doInBucket(CouchbaseTemplate.java:490) ~[spring-data-couchbase-2.1.3.RELEASE.jar:na]
	at org.springframework.data.couchbase.core.CouchbaseTemplate$8.doInBucket(CouchbaseTemplate.java:487) ~[spring-data-couchbase-2.1.3.RELEASE.jar:na]
	at org.springframework.data.couchbase.core.CouchbaseTemplate.execute(CouchbaseTemplate.java:530) ~[spring-data-couchbase-2.1.3.RELEASE.jar:na]
	... 81 common frames omitted
Caused by: java.util.concurrent.TimeoutException: null
	... 87 common frames omitted

Hi @daschl, suggestions?

@mariusz.kopylec two things here. to debug that specific issue it might make sense to crank up the logging level to TRACE log so we can follow the request response times. What is your client side timeout?

Also in your case you can just use the “remove” operation on the SDK since you are just deleting one document. Performance doesn’t matter much here I think but its just easier to write as you have it available on the spring template as well.

Also try cranking up the timeout even more and see what the actual response time is.

btw, if you run this in a test environment and you want to clean out your bucket you can also consider using the flush operation.

@daschl thanks for response.
The correct delete statement is String statement = "DELETE FROM " + bucket;
My client side timeout is 7,5 seconds.
I’ll try the flush() method and to increase the timeout. I’ll also provide TRACE logs.

About the flush(). Is it gonna remove all documents from bucket, even if they weren’t indexed?

Here is the test log http://www.filedropper.com/test-log
The flush() method doesn’t seem to delete documents that are not indexed.

I’ve increased the query client timeout to 20 seconds and that seems to work. The error no longer appears.