Unexpected error occurred in scheduled task

Can someone explain why this exception is coming:

|Unexpected error occurred in scheduled task.
org.springframework.data.couchbase.core.CouchbaseQueryExecutionException: Unable to execute query due to the following n1ql errors:
at org.springframework.data.couchbase.core.CouchbaseTemplate.findByN1QL(CouchbaseTemplate.java:448)
at org.springframework.data.couchbase.repository.query.AbstractN1qlBasedQuery.executeCollection(AbstractN1qlBasedQuery.java:158)
at org.springframework.data.couchbase.repository.query.AbstractN1qlBasedQuery.executeDependingOnType(AbstractN1qlBasedQuery.java:133)
at org.springframework.data.couchbase.repository.query.AbstractN1qlBasedQuery.execute(AbstractN1qlBasedQuery.java:104)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.couchbase.repository.support.ViewPostProcessor$ViewInterceptor.invoke(ViewPostProcessor.java:87)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)

Itz intermittent issue. Working on local machine but failing on staging machine having two servers in cluster. I am clueless. Is it timeout issue, but query is executing in 35 ms. And I believe default timeout is 75 seconds.

Spring Boot version: 1.5.2.RELEASE
Java: 8
Spring-Data couchbase client version: 2.2.0.RELEASE

Guys, any inputs on this. Still I am stuck on this. Tried following approach:

  • Executing request on one node separately.
  • Creating N1QL query using @Query tag in Spring-Data.

Hi @nitin.upadhyay,

You may want to ask Spring questions in the Java forum: https://www.couchbase.com/forums/c/java-sdk

I’m tagging @ingenthr and @subhashni, they might be able to help.

Is there anything different during the times it happens? Any load or cluster topology changes?

It appears to be Spring Data Couchbase related, and could be in some of the abstract/core classes from Spring Data to my read. 2.2.0 is quite old at this point. Can you upgrade to 2.2.10 (the current maintenance release in the series) to see if you still see the same thing?

Also, note that the IO for query execution happens on a separate thread, so it may be good to look in your log for other warning/error info that correlates.

Any other thoughts @subhashni?

It doesn’t look like timeout from the stack trace, however the error messages are missing. You can check the query that is executed by enabling debug logs on the query repository, for example in logback
<logger name="org.springframework.data.couchbase.repository.query" level="debug"/> and check if it works on cli/query gui.

I am getting below query and exception:

o.s.d.c.r.q.AbstractN1qlBasedQuery.logIfNecessary(152) | | |Executing N1QL query: {“statement”:“SELECT META(Gateway).id AS _ID, META(Gateway).cas AS _CAS, Gateway.* FROM Gateway WHERE nextExpire >= $after and nextExpire < $before and _class = “com.vodafone.id.gateway.consent.entity.SubRemembers””,"$before":1519216153880,"$after":0,“scan_consistency”:“statement_plus”}
2018-02-21 12:29:14,076 | CID-GW-BE-CONSENT | registrationTask1 | ERROR | o.s.s.s.TaskUtils$LoggingErrorHandler.handleError(95) | | |Unexpected error occurred in scheduled task.
org.springframework.data.couchbase.core.CouchbaseQueryExecutionException: Unable to execute query due to the following n1ql errors:
at org.springframework.data.couchbase.core.CouchbaseTemplate.findByN1QL(CouchbaseTemplate.java:448)
at org.springframework.data.couchbase.repository.query.AbstractN1qlBasedQuery.executeCollection(AbstractN1qlBasedQuery.java:158)
at org.springframework.data.couchbase.repository.query.AbstractN1qlBasedQuery.executeDependingOnType(AbstractN1qlBasedQuery.java:133)
at org.springframework.data.couchbase.repository.query.AbstractN1qlBasedQuery.execute(AbstractN1qlBasedQuery.java:104)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)

I tried to upgrade the version of spring data couchbase to 2.2.10 but it is not compatible with spring-boot.version 1.5.2. Could you please suggest for which spring boot verson, it is compatible?