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

select count(*) errors with prepared statement and request_plus consistency

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.1.2, 4.5.1, 5.0.0
    • 4.1.0
    • query
    • None
    • Untriaged
    • Unknown

    Description

      https://forums.couchbase.com/t/moved-javasdk-couchbaseserver-n1ql-for-4-1-x-count-problem/8213/12

      And my questions are still same:
      1) how can i benefit from prepared statement in this case, i.e. how to skip plan preparation phase ?
      2) should i use count(a) or count is "smart enough" to pre-optimize query and use only secondary index data to count ? Index = "create index on bucket(a,b) where a is valued".
      3) Where can i find docs about returned messages error codes detailed description ?
      + 4) What about this error:

      {"msg":"Encoded plan parameter does not match encoded plan of 6d44613366b67887374b910295a09171847a79c1","code":4080}

      Repro-sample test:
      ================
      i wrote a simple sync-test (code) below, and multiple runs tells me that there are stable 2 errors for COUNT(1) per each 100 calls for separate run:

      0 =>[

      {"msg":"Encoded plan parameter does not match encoded plan of 3e5d691a6480801871cae0bffb4814ab34d2befc","code":4080}

      ]
      1 =>[

      {"msg":"Encoded plan parameter does not match encoded plan of 3e5d691a6480801871cae0bffb4814ab34d2befc","code":4080}

      ]
      DONE with i = 100
      Create 3 indexes like:
      "create index i1 on bucket.name(a,b) where a is valued;"
      "create index i2 on bucket.name(a,b) where a is valued;"
      "create index i3 on bucket.name(a,b) where a is valued;"

      You can use even empty buckets. Then run the code :

      package n1qlcount;

      import com.couchbase.client.java.Bucket;
      import com.couchbase.client.java.Cluster;
      import com.couchbase.client.java.CouchbaseCluster;
      import com.couchbase.client.java.document.json.JsonArray;
      import com.couchbase.client.java.env.CouchbaseEnvironment;
      import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
      import com.couchbase.client.java.query.N1qlParams;
      import com.couchbase.client.java.query.N1qlQuery;
      import com.couchbase.client.java.query.N1qlQueryResult;
      import com.couchbase.client.java.query.consistency.ScanConsistency;
      import java.util.Collections;
      import java.util.LinkedList;

      public class N1QLCount {

      public static void main(String[] args) {
      CouchbaseEnvironment ce = DefaultCouchbaseEnvironment.create();
      final LinkedList<String> nodes = new LinkedList();
      nodes.add("A");
      nodes.add("B");
      nodes.add("C");
      Cluster cluster = CouchbaseCluster.create(ce, nodes);
      final String bucketName = "bucket.name";
      final String bucketPass = "password";
      final String fieldA = "a";
      final String fieldB = "b";
      Bucket b = cluster.openBucket(bucketName, bucketPass);
      final N1qlParams p = N1qlParams
      .build()
      .adhoc(false)
      .consistency(ScanConsistency.REQUEST_PLUS);
      final String Q =
      "SELECT COUNT(1) from `"
      + bucketName
      + "` WHERE "
      + fieldA
      + "=$1 AND "
      + fieldB
      + "=$2;";
      JsonArray ja = null;
      N1qlQueryResult r = null;
      int count = 100, i = 0;
      for(i = 0; i< count; i++) {
      ja = JsonArray.empty().add("A" + i).add("B" + i);
      r = b.query(N1qlQuery.parameterized(Q, ja , p));
      if(r.errors().size() > 0)

      { System.out.println(i + " =>" + r.errors().toString()); }

      }
      System.out.println("DONE with i = " + i);
      b.close();
      }
      }
      So, it's defenetly a bug for 4.1.x. The question is "what we gonna do with this" ?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Prerna.Manaktala Prerna Manaktala (Inactive)
              Prasad.Varakur Prasad Varakur
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty