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

    • Untriaged
    • 1
    • 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

            Sitaram.Vemulapalli Sitaram Vemulapalli created issue -
            Sitaram.Vemulapalli Sitaram Vemulapalli made changes -
            Field Original Value New Value
            Link This issue is triggered by CBSE-10755 [ CBSE-10755 ]

            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.

            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.
            bingjie.miao Bingjie Miao made changes -
            Assignee Kamini Jagtiani [ kamini.jagtiani ] Bingjie Miao [ bingjie.miao ]
            Sitaram.Vemulapalli Sitaram Vemulapalli made changes -
            Summary panic is the planner When more than one key sargable, but first key generates empty span it panics
            Sitaram.Vemulapalli Sitaram Vemulapalli made changes -
            Summary When more than one key sargable, but first key generates empty span it panics More than one key sargable, but first key generates empty span it panics
            Sitaram.Vemulapalli Sitaram Vemulapalli made changes -
            Affects Version/s 7.0.2 [ 18012 ]
            Sitaram.Vemulapalli Sitaram Vemulapalli made changes -
            Fix Version/s 7.0.3 [ 18033 ]
            Fix Version/s 6.6.4 [ 17614 ]
            bingjie.miao Bingjie Miao made changes -
            Is this a Regression? Unknown [ 10452 ] Yes [ 10450 ]
            bingjie.miao Bingjie Miao made changes -
            Link This issue is caused by MB-30422 [ MB-30422 ]

            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

            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
            kamini.jagtiani Kamini Jagtiani made changes -
            Fix Version/s 7.0.2 [ 18012 ]
            Fix Version/s 7.0.3 [ 18033 ]
            wayne Wayne Siu made changes -
            Link This issue blocks MB-46308 [ MB-46308 ]
            wayne Wayne Siu made changes -
            Labels approved-for-7.0.2

            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

            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
            wayne Wayne Siu made changes -
            Link This issue blocks MB-47673 [ MB-47673 ]
            wayne Wayne Siu made changes -
            Labels approved-for-7.0.2 approved-for-6.6.4 approved-for-7.0.2

            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

            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
            bingjie.miao Bingjie Miao made changes -
            Assignee Bingjie Miao [ bingjie.miao ] Mihir Kamdar [ mihir.kamdar ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Resolved [ 5 ]
            mihir.kamdar Mihir Kamdar (Inactive) made changes -
            Assignee Mihir Kamdar [ mihir.kamdar ] Pierre Regazzoni [ JIRAUSER25157 ]

            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
                }
            }
             

            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 } }
            pierre.regazzoni Pierre Regazzoni made changes -
            Status Resolved [ 5 ] Closed [ 6 ]
            wayne Wayne Siu made changes -
            Link This issue blocks MB-49253 [ MB-49253 ]

            Build couchbase-server-6.6.3-9814 contains query commit e3e4365 with commit message:
            MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length

            build-team Couchbase Build Team added a comment - Build couchbase-server-6.6.3-9814 contains query commit e3e4365 with commit message: MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length

            Verified on 6.6.3-9814

            cbq> EXPLAIN SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;
            {
                "requestID": "10343715-db9b-4d49-8102-17a1a8f8634c",
                "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_covers": {
                                        "cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end)": true
                                    },
                                    "index": "ix1",
                                    "index_id": "ba22601f43902e69",
                                    "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": "Filter",
                                            "condition": "(cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end) and (cover ((`default`.`c1`)) = 5))"
                                        },
                                        {
                                            "#operator": "InitialProject",
                                            "result_terms": [
                                                {
                                                    "expr": "1"
                                                }
                                            ]
                                        },
                                        {
                                            "#operator": "FinalProject"
                                        }
                                    ]
                                }
                            }
                        ]
                    },
                    "text": "SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;"
                }
                ],
                "status": "success",
                "metrics": {
                    "elapsedTime": "6.840699ms",
                    "executionTime": "6.626153ms",
                    "resultCount": 1,
                    "resultSize": 2784
                }
            } 

            pierre.regazzoni Pierre Regazzoni added a comment - Verified on 6.6.3-9814 cbq> EXPLAIN SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5 ; { "requestID" : "10343715-db9b-4d49-8102-17a1a8f8634c" , "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_covers" : { "cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end)" : true }, "index" : "ix1" , "index_id" : "ba22601f43902e69" , "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" : "Filter" , "condition" : "(cover (any `v` in (`default`.`arr1`) satisfies ((`v`.`id`) in []) end) and (cover ((`default`.`c1`)) = 5))" }, { "#operator" : "InitialProject" , "result_terms" : [ { "expr" : "1" } ] }, { "#operator" : "FinalProject" } ] } } ] }, "text" : "SELECT 1 FROM default WHERE ANY v IN arr1 SATISFIES v.id IN [] END AND c1 = 5;" } ], "status" : "success" , "metrics" : { "elapsedTime" : "6.840699ms" , "executionTime" : "6.626153ms" , "resultCount" : 1 , "resultSize" : 2784 } }

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

            build-team Couchbase Build Team added a comment - Build couchbase-server-6.6.4-9960 contains query commit e3e4365 with commit message: MB-48547 In case of EMPTY_SPANS return a slice of EMPTY_SPANS with proper length
            wayne Wayne Siu made changes -
            Link This issue blocks MB-50048 [ MB-50048 ]

            Verified on 6.6.5-10060

            pierre.regazzoni Pierre Regazzoni added a comment - Verified on 6.6.5-10060
            wayne Wayne Siu made changes -
            Link This issue blocks MB-50049 [ MB-50049 ]
            wayne Wayne Siu made changes -
            Fix Version/s 6.6.4 [ 18218 ]

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty