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

Query: Collection select produces unstable results

    XMLWordPrintable

Details

    Description

      Build: 7.0.0-2261

      Cluster of 2 nodes: kv:query:index, kv:query:index

      bucket bucket1 contains the following scopes and collections:

       

      bucket1.scope1.collection1
      bucket1.scope1.collection2
      

       

      Both collections are provided with primary indexes:

       

      CREATE PRIMARY INDEX `#primary` ON `bucket1`.`scope1`.`collection1`
      CREATE PRIMARY INDEX `#primary` ON `bucket1`.`scope1`.`collection2` 
      

      Dataset for collection1 is:

      [
       {
       "collection1": {
       "name": "default:bucket1.scope1.collection1_name_updated_updated",
       "val": 1
       },
       "id": "default:bucket1.scope1.collection1_id"
       },
       {
       "collection1": {
       "name": "default:bucket1.scope1.collection1_name2",
       "val": 2
       },
       "id": "default:bucket1.scope1.collection1_id1"
       }
      ]

      Dataset for collection2 is:

      [
       {
       "collection2": {
       "name": "default:bucket1.scope1.collection2_name_updated",
       "val": 1
       },
       "id": "default:bucket1.scope1.collection2_id"
       },
       {
       "collection2": {
       "name": "default:bucket1.scope1.collection2_name2",
       "val": 2
       },
       "id": "default:bucket1.scope1.collection2_id1"
       }
      ]

      Running query like 

      select * from default:bucket1.scope1.collection1

      or

      select * from default:bucket1.scope1.collection2

      produces sometimes correct result set, sometimes empty dataset.

      Explain plan for empty (incorrect) dataset:

      {
          "#operator": "Sequence",
          "~children": [
              {
                  "#operator": "PrimaryScan3",
                  "bucket": "bucket1",
                  "index": "#primary",
                  "index_projection": {
                      "primary_key": true
                  },
                  "keyspace": "collection2",
                  "namespace": "default",
                  "scope": "scope1",
                  "using": "gsi"
              },
              {
                  "#operator": "Fetch",
                  "bucket": "bucket1",
                  "keyspace": "collection2",
                  "namespace": "default",
                  "scope": "scope1"
              },
              {
                  "#operator": "Parallel",
                  "~child": {
                      "#operator": "Sequence",
                      "~children": [
                          {
                              "#operator": "InitialProject",
                              "result_terms": [
                                  {
                                      "expr": "self",
                                      "star": true
                                  }
                              ]
                          }
                      ]
                  }
              }
          ]
      }

      Explain plan for correct result set:

      {
          "#operator": "Sequence",
          "~children": [
              {
                  "#operator": "PrimaryScan3",
                  "bucket": "bucket1",
                  "index": "#primary",
                  "index_projection": {
                      "primary_key": true
                  },
                  "keyspace": "collection2",
                  "namespace": "default",
                  "scope": "scope1",
                  "using": "gsi"
              },
              {
                  "#operator": "Fetch",
                  "bucket": "bucket1",
                  "keyspace": "collection2",
                  "namespace": "default",
                  "scope": "scope1"
              },
              {
                  "#operator": "Parallel",
                  "~child": {
                      "#operator": "Sequence",
                      "~children": [
                          {
                              "#operator": "InitialProject",
                              "result_terms": [
                                  {
                                      "expr": "self",
                                      "star": true
                                  }
                              ]
                          }
                      ]
                  }
              }
          ]
      }

      Attachments

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

        Activity

          People

            ajay.bhullar Ajay Bhullar
            evgeny.makarenko Evgeny Makarenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty