Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-28876

Using N1QL prepared statement with 4000 error code

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Critical
    • 5.5.0
    • 5.1.0
    • query, secondary-index
    • Java SDK 2.5.5
    • Untriaged
    • Centos 64-bit
    • Unknown

    Description

      Hi,

      I’m facing an issue actually when using adhoc(false) for prepared statement :

       

      JsonObject placeholderValues = JsonObject.create().put("typed", Consts.JSON_TYPE_DOCUMENT_CONNEXION_DATE).put("contactid", contact_id).put("maxItems", maxItems);
      N1qlParams params = N1qlParams.build().adhoc(false).consistency(ScanConsistency.valueOf(env.getProperty(CONSISTENCY_LEVEL_SELECT_ACCESS_LOGS)));
      ParameterizedN1qlQuery query = N1qlQuery.parameterized(SELECT_ACCESS_LOGS, placeholderValues, params);
      N1qlQueryResult result1 = bucket.query(query);
      

      We have this Java stacktrace

      15:15:42.316 INFO  com.accor.poc.co.LauncherAccorCO:48 - Starting LauncherAccorCO v0.0.1-SNAPSHOT on AURELIEN with PID 19304 (C:\Users\Aurelien\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp3\wtpwebapps\accor-poc-co\WEB-INF\classes started by Aurelien in D:\webcaruel\Environnement\eclipse)
      15:15:42.335 DEBUG com.accor.poc.co.LauncherAccorCO:51 - Running with Spring Boot v1.5.1.RELEASE, Spring v4.3.6.RELEASE
      15:15:42.336 INFO  com.accor.poc.co.LauncherAccorCO:637 - No active profile set, falling back to default profiles: default
      15:15:46.941 INFO  com.accor.poc.co.LauncherAccorCO:57 - Started LauncherAccorCO in 5.458 seconds (JVM running for 22.419)
      15:15:46.953 DEBUG com.accor.poc.co.filters.CorsFilter:177 - Initializing filter 'corsFilter'
      15:15:46.954 DEBUG com.accor.poc.co.filters.CorsFilter:202 - Filter 'corsFilter' configured successfully
      15:15:47.230 DEBUG com.accor.poc.co.controller.ControllerContacts:57 - http_header_x_key pmid 
      ....java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)
      Caused by: com.couchbase.client.core.CouchbaseException: N1qlQuery Error - {"msg":"No index available on keyspace accor that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.","code":4000}
          at com.couchbase.client.java.query.core.N1qlQueryExecutor$11$4.call(N1qlQueryExecutor.java:513)
          at com.couchbase.client.java.query.core.N1qlQueryExecutor$11$4.call(N1qlQueryExecutor.java:508)
          at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
          at rx.internal.operators.NotificationLite.accept(NotificationLite.java:135)
          at rx.internal.operators.OperatorOnBackpressureBuffer$BufferSubscriber.accept(OperatorOnBackpressureBuffer.java:156)
          at rx.internal.util.BackpressureDrainManager.drain(BackpressureDrainManager.java:198)
          at rx.internal.operators.OperatorOnBackpressureBuffer$BufferSubscriber.onNext(OperatorOnBackpressureBuffer.java:151)
          at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:134)
          at rx.internal.operators.NotificationLite.accept(NotificationLite.java:135)
          ... 41 common frames omitted

       If using adhoc to true, it’s passing ! But the usage of node CPU is to hight in comparaison to Cassandra usage.

      Has the parsing and execution plan is done each request, I want to force the usage of adhoc to false, but I don’t have a clue of why we have this issue.

      You have the index in attachment, maybe to use adhoc to false, we have to change index creation?

      Do you have an idea?

      Je Java SDk code is in attachment, also for Index.txt for index creation.

      Thank you for any help. 

      Regards

      Attachments

        1. accor-poc-co_20032018.zip
          38 kB
        2. Index.txt
          1 kB
        3. JavaStackTrace.txt
          9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            marco.greco Marco Greco (Inactive)
            bruno.guedes Bruno Guedes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty