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

More than one key sargable, but first key generates empty span it panics

    XMLWordPrintable

    Details

    • Triage:
      Untriaged
    • Story Points:
      1
    • Is this a Regression?:
      Yes

      Description

       create index ix1 ON default(DISTINCT ARRAY v.id FOR v IN arr1 END, c1);
      EXPLAIN SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;
      
      

      2021-09-21T17:12:36.138-07:00 [SEVERE] request text: <ud>EXPLAIN SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;</ud>
      2021-09-21T17:12:36.138-07:00 [SEVERE] query context: <ud></ud>
      2021-09-21T17:12:36.138-07:00 [SEVERE] stack: goroutine 350 [running]:
      github.com/couchbase/query/server.(*Server).serviceRequest.func1(0x5ba83c0, 0xc000d16000, 0xc0005f0000)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/server/server.go:924 +0xbe
      panic(0x5687860, 0xc00117e1e0)
      	/usr/local/Cellar/go/1.13.7/libexec/src/runtime/panic.go:679 +0x1b2
      github.com/couchbase/query/planner.SargForFilters(0xc000c05ab0, 0x2, 0x2, 0xc001133020, 0x2, 0x2, 0x2, 0xa800000, 0xc000aea0c0, 0xc0011629f0, ...)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/planner/sarg.go:115 +0xa8c
      github.com/couchbase/query/planner.(*builder).sargIndexes(0xc001166000, 0xc000aea0c0, 0xc001178f00, 0xc001178f28, 0x6d77260, 0xc001178b00)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/planner/build_scan_secondary.go:673 +0x769
      github.com/couchbase/query/planner.(*builder).buildCoveringScan(0xc001166000, 0xc001163380, 0xc001128300, 0xc000aea0c0, 0x5b72fa0, 0xc000578f50, 0x0, 0x0, 0x0, 0x0, ...)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/planner/build_scan_covering.go:102 +0xa75
      github.com/couchbase/query/planner.(*builder).buildCovering(0xc001166000, 0xc001163380, 0x0, 0xc001128300, 0xc000aea0c0, 0x5b72fa0, 0xc000578f50, 0x0, 0x0, 0x0, ...)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/planner/build_scan_covering.go:36 +0x104
      github.com/couchbase/query/planner.(*builder).buildSecondaryScan(0xc001166000, 0xc001163380, 0x0, 0xc001128300, 0xc000aea0c0, 0x5b72fa0, 0xc000578f50, 0x0, 0x0, 0x0, ...)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/planner/build_scan_secondary.go:29 +0xb8
      github.com/couchbase/query/planner.(*builder).buildTermScan(0xc001166000, 0xc001128300, 0xc000aea0c0, 0x5b72fa0, 0xc000578f50, 0xc0011c8000, 0x5, 0x100, 0xc000c05b60, 0x1, ...)
      	/Users/sitaram/trans/query/src/github.com/couchbase/query/planner/build_scan.go:407 +0x69d
      github.com/couchbase/query/planner.(*builder).buildSubsetScan(0xc001166000, 0x5b57b40, 0xc000c7cf70, 0xc001128300, 0xc000aea0c0, 0x5b72fa0, 0xc000578f50, 0xc0011c8000, 0x5, 0x100, ...)
      

        Attachments

          Issue Links

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

            Activity

            Hide
            Sitaram.Vemulapalli Sitaram Vemulapalli added a comment -

            As there is no values IN first key might be empty span. Once one key empty others will automatically empty and not generated. but we are access second.

            Show
            Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - As there is no values IN first key might be empty span. Once one key empty others will automatically empty and not generated. but we are access second.
            Hide
            build-team Couchbase Build Team added a comment -

            Build couchbase-server-7.1.0-1326 contains query commit 0f5276a with commit message:
            MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length

            Show
            build-team Couchbase Build Team added a comment - Build couchbase-server-7.1.0-1326 contains query commit 0f5276a with commit message: MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length
            Hide
            build-team Couchbase Build Team added a comment -

            Build couchbase-server-7.0.2-6689 contains query commit 8af9b68 with commit message:
            MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length

            Show
            build-team Couchbase Build Team added a comment - Build couchbase-server-7.0.2-6689 contains query commit 8af9b68 with commit message: MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length
            Hide
            build-team Couchbase Build Team added a comment -

            Build couchbase-server-6.6.4-9920 contains query commit 3409d32 with commit message:
            MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length

            Show
            build-team Couchbase Build Team added a comment - Build couchbase-server-6.6.4-9920 contains query commit 3409d32 with commit message: MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length
            Hide
            pierre.regazzoni Pierre Regazzoni added a comment -

            Verified on 6.6.4-9920, 7.0.2-6694 and 7.1.0-1360

            cbq> EXPLAIN SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;
            {
                "requestID": "32802eec-a5a0-434a-aba8-3ffe7d1e6183",
                "signature": "json",
                "results": [
                {
                    "plan": {
                        "#operator": "Sequence",
                        "~children": [
                            {
                                "#operator": "DistinctScan",
                                "scan": {
                                    "#operator": "IndexScan3",
                                    "covers": [
                                        "cover ((distinct (array (`v`.`id`) for `v` in (`default`.`arr1`) end)))",
                                        "cover ((`default`.`c1`))",
                                        "cover ((meta(`default`).`id`))"
                                    ],
                                    "filter": "(cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end) and (cover ((`default`.`c1`)) = 5))",
                                    "filter_covers": {
                                        "cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end)": true
                                    },
                                    "index": "ix1",
                                    "index_id": "d76b13aa35e02595",
                                    "index_projection": {
                                        "entry_keys": [
                                            1
                                        ],
                                        "primary_key": true
                                    },
                                    "keyspace": "default",
                                    "namespace": "default",
                                    "spans": [
                                        {
                                            "exact": true,
                                            "range": [
                                                {
                                                    "high": "null",
                                                    "inclusion": 0,
                                                    "low": "null"
                                                }
                                            ]
                                        }
                                    ],
                                    "using": "gsi"
                                }
                            },
                            {
                                "#operator": "Parallel",
                                "~child": {
                                    "#operator": "Sequence",
                                    "~children": [
                                        {
                                            "#operator": "InitialProject",
                                            "result_terms": [
                                                {
                                                    "expr": "1"
                                                }
                                            ]
                                        }
                                    ]
                                }
                            }
                        ]
                    },
                    "text": "SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;"
                }
                ],
                "status": "success",
                "metrics": {
                    "elapsedTime": "6.927468ms",
                    "executionTime": "6.736419ms",
                    "resultCount": 1,
                    "resultSize": 2537,
                    "serviceLoad": 6
                }
            }
             

            Show
            pierre.regazzoni Pierre Regazzoni added a comment - Verified on 6.6.4-9920, 7.0.2-6694 and 7.1.0-1360 cbq> EXPLAIN SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5 ; { "requestID" : "32802eec-a5a0-434a-aba8-3ffe7d1e6183" , "signature" : "json" , "results" : [ { "plan" : { "#operator" : "Sequence" , "~children" : [ { "#operator" : "DistinctScan" , "scan" : { "#operator" : "IndexScan3" , "covers" : [ "cover ((distinct (array (`v`.`id`) for `v` in (`default`.`arr1`) end)))" , "cover ((`default`.`c1`))" , "cover ((meta(`default`).`id`))" ], "filter" : "(cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end) and (cover ((`default`.`c1`)) = 5))" , "filter_covers" : { "cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end)" : true }, "index" : "ix1" , "index_id" : "d76b13aa35e02595" , "index_projection" : { "entry_keys" : [ 1 ], "primary_key" : true }, "keyspace" : "default" , "namespace" : "default" , "spans" : [ { "exact" : true , "range" : [ { "high" : "null" , "inclusion" : 0 , "low" : "null" } ] } ], "using" : "gsi" } }, { "#operator" : "Parallel" , "~child" : { "#operator" : "Sequence" , "~children" : [ { "#operator" : "InitialProject" , "result_terms" : [ { "expr" : "1" } ] } ] } } ] }, "text" : "SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;" } ], "status" : "success" , "metrics" : { "elapsedTime" : "6.927468ms" , "executionTime" : "6.736419ms" , "resultCount" : 1 , "resultSize" : 2537 , "serviceLoad" : 6 } }

              People

              Assignee:
              pierre.regazzoni Pierre Regazzoni
              Reporter:
              Sitaram.Vemulapalli Sitaram Vemulapalli
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                    PagerDuty