N1QL + SEARCH clause with named parameter results in runtime error

Dear all,

We ran into following issue with Couchbase Community Edition 7.1.0 build 2556.

N1QL with SEARCH clause works without named parameter.

However, it fails if a named parameter is used.

Runtime Error:

[
  {
    "code": 5001,
    "msg": "Panic: runtime error: invalid memory address or nil pointer dereference",
    "query": "SELECT meta(r).id\nFROM resources r\nWHERE SEARCH(r, $query, {\"index\":\"search-index-v1\"})\nLIMIT 1;"
  }
]

Are named parameters supported in SEARCH clause of N1QL?

It shouldn’t be panicking; could you share the details (stack) from the query.log ?

As @dh mentioned it should not panic. Provide stack we will fix that.

Try this

SELECT meta(r).id
FROM resources r
WHERE SEARCH(r, {"query":$val }, {"index":"search-index-v1"})
LIMIT 1;

cc @abhinav

@Vinaya_Kumar_B need more information from you here.

  • I see where you’re setting $query but I don’t see the index definition you’re using.

And in case of panics - sharing the stack trace or logs is quite necessary for us to debug. You should be able to download logs for your couchbase node(s) from the Logs tab on your console.

Hi @abhinav, index definition is given below for your reference.

{
  "type": "fulltext-index",
  "name": "search-index-v1",
  "uuid": "3407ec390b4b8849",
  "sourceType": "gocbcore",
  "sourceName": "KWATenantData",
  "sourceUUID": "87e74dda02c4ac4f3b4f167a7263790a",
  "planParams": {
    "maxPartitionsPerPIndex": 1024,
    "indexPartitions": 1
  },
  "params": {
    "doc_config": {
      "docid_prefix_delim": "",
      "docid_regexp": "",
      "mode": "scope.collection.type_field",
      "type_field": "resource_type"
    },
    "mapping": {
      "analysis": {},
      "default_analyzer": "standard",
      "default_datetime_parser": "dateTimeOptional",
      "default_field": "_all",
      "default_mapping": {
        "dynamic": true,
        "enabled": false
      },
      "default_type": "_default",
      "docvalues_dynamic": false,
      "index_dynamic": true,
      "store_dynamic": false,
      "type_field": "_type",
      "types": {
        "transaction.resources": {
          "dynamic": false,
          "enabled": true,
          "properties": {
            "data_lake_snapshot_key": {
              "dynamic": false,
              "enabled": true,
              "properties": {
                "cloud_account": {
                  "dynamic": false,
                  "enabled": true,
                  "properties": {
                    "account_id": {
                      "dynamic": false,
                      "enabled": true,
                      "fields": [
                        {
                          "docvalues": true,
                          "include_in_all": true,
                          "include_term_vectors": true,
                          "index": true,
                          "name": "account_id",
                          "store": true,
                          "type": "text"
                        }
                      ]
                    },
                    "cloud_provider": {
                      "dynamic": false,
                      "enabled": true,
                      "fields": [
                        {
                          "docvalues": true,
                          "include_in_all": true,
                          "include_term_vectors": true,
                          "index": true,
                          "name": "cloud_provider",
                          "store": true,
                          "type": "text"
                        }
                      ]
                    }
                  }
                },
                "resource_snapshot_id": {
                  "dynamic": false,
                  "enabled": true,
                  "fields": [
                    {
                      "docvalues": true,
                      "include_in_all": true,
                      "include_term_vectors": true,
                      "index": true,
                      "name": "resource_snapshot_id",
                      "store": true,
                      "type": "text"
                    }
                  ]
                }
              }
            },
            "resource_data": {
              "dynamic": true,
              "enabled": true
            },
            "resource_key": {
              "dynamic": false,
              "enabled": true,
              "fields": [
                {
                  "docvalues": true,
                  "include_in_all": true,
                  "include_term_vectors": true,
                  "index": true,
                  "name": "resource_key",
                  "store": true,
                  "type": "text"
                }
              ]
            },
            "resource_type": {
              "dynamic": false,
              "enabled": true,
              "fields": [
                {
                  "analyzer": "simple",
                  "docvalues": true,
                  "include_in_all": true,
                  "include_term_vectors": true,
                  "index": true,
                  "name": "resource_type",
                  "store": true,
                  "type": "text"
                }
              ]
            }
          }
        }
      }
    },
    "store": {
      "indexType": "scorch",
      "segmentVersion": 15
    }
  },
  "sourceParams": {}
}

Following stack trace is observed in query.log.

2022-06-08T15:45:03.560+00:00 [Info] GsiClient::UpdateUsecjson: using collatejson as data format between indexer and GsiClient
2022-06-08T15:45:03.562+00:00 [SEVERE] panic: runtime error: invalid memory address or nil pointer dereference
2022-06-08T15:45:03.562+00:00 [SEVERE] request text: <ud>SELECT meta(r).id
FROM `resources` r
WHERE SEARCH(r, $query, {"index":"search-index-v1"})
LIMIT 1;</ud>
2022-06-08T15:45:03.562+00:00 [SEVERE] query context: <ud>default:KWATenantData.transaction</ud>
2022-06-08T15:45:03.562+00:00 [SEVERE] stack: goroutine 1176473 [running]:
github.com/couchbase/query/server.(*Server).serviceRequest.func1(0x1e5a1a8, 0xc001e4a000, 0xc0000b8400)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:958 +0xc6
panic(0x18ac700, 0x2cb9ad0)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/runtime/panic.go:965 +0x1b9
github.com/couchbase/n1fty.(*FTSIndex).buildQueryAndCheckIfSargable(0xc000989380, 0x0, 0x0, 0x0, 0x0, 0x1e16b20, 0xc002b471d0, 0x0, 0x0, 0xc0017d75e0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:685 +0xb56
github.com/couchbase/n1fty.(*FTSIndex).Sargable(0xc000989380, 0x0, 0x0, 0x1e1f9d8, 0xc000b35ac0, 0x1e2eab8, 0xc000b35dc0, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:415 +0x10c
github.com/couchbase/query/planner.(*builder).sargableSearchIndexes(0xc0024403c0, 0xc000a63000, 0xe, 0x100, 0x1e353c8, 0xc0003c22d0, 0xc000c61950, 0xc0017d7a40, 0xc001b63e60, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan_search.go:292 +0x6b6
github.com/couchbase/query/planner.(*builder).buildTermScan(0xc0024403c0, 0xc000ead100, 0xc0009d80f0, 0x1e28d30, 0xc003cdea20, 0xc000a63000, 0xe, 0x100, 0xc001b63e60, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:394 +0x1465
github.com/couchbase/query/planner.(*builder).buildSubsetScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0xc0009d80f0, 0x1e28d30, 0xc003cdea20, 0xc000a63000, 0xe, 0x100, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:291 +0x1f4
github.com/couchbase/query/planner.(*builder).buildPredicateScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0xc0009d80f0, 0x1e28d30, 0xc003cdea20, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:240 +0x38d
github.com/couchbase/query/planner.(*builder).buildScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:163 +0x879
github.com/couchbase/query/planner.(*builder).selectScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0x0, 0x0, 0xc000c62188, 0xaa890a, 0xc000ead680)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:52 +0x3b8
github.com/couchbase/query/planner.(*builder).VisitKeyspaceTerm(0xc0024403c0, 0xc000ead100, 0x203000, 0x203000, 0x0, 0x3000106)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:255 +0x185
github.com/couchbase/query/algebra.(*KeyspaceTerm).Accept(...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_keyspace.go:72
github.com/couchbase/query/planner.(*builder).VisitExpressionTerm(0xc0024403c0, 0xc000b35a80, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:398 +0x6f3
github.com/couchbase/query/algebra.(*ExpressionTerm).Accept(0xc000b35a80, 0x1e0e128, 0xc0024403c0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_expression.go:40 +0x3b
github.com/couchbase/query/planner.(*builder).visitFrom(0xc0024403c0, 0xc0003c2090, 0x0, 0xc0001577e0, 0xc000c62cd0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:176 +0x13a7
github.com/couchbase/query/planner.(*builder).VisitSubselect(0xc0024403c0, 0xc0003c2090, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_sub.go:236 +0xa0a
github.com/couchbase/query/algebra.(*Subselect).Accept(0xc0003c2090, 0x1e0e128, 0xc0024403c0, 0x1e261a0, 0xc000b35c40, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select_sub.go:60 +0x3e
github.com/couchbase/query/planner.(*builder).VisitSelect(0xc0024403c0, 0xc003cde900, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select.go:71 +0x2ca
github.com/couchbase/query/algebra.(*Select).Accept(0xc003cde900, 0x1e15a40, 0xc0024403c0, 0xc002b46c90, 0x8, 0x1a8fd00, 0x1aff660)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select.go:58 +0x3e
github.com/couchbase/query/planner.Build(0x1e02938, 0xc003cde900, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0x1ae0100, 0xc000ead180, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build.go:31 +0x18a
github.com/couchbase/query/planner.BuildPrepared(0x1e02938, 0xc003cde900, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0xc003cd0100, 0xc000ead180, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_prepared.go:19 +0xc5
github.com/couchbase/query/server.(*Server).getPrepared(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000, 0xc000872000, 0x0, 0xc000b359c0, 0x1b9ee5f)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1216 +0x120d
github.com/couchbase/query/server.(*Server).serviceRequest(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1013 +0x225
github.com/couchbase/query/server.(*Server).handleRequest(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000, 0xc0000b8430, 0x9)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:664 +0x6e
github.com/couchbase/query/server.(*Server).ServiceRequest(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:593 +0x79
github.com/couchbase/query/server/http.(*HttpEndpoint).ServeHTTP(0xc0005d2000, 0x1de3810, 0xc00145e700, 0xc001325300)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/http/service_endpoint.go:443 +0x393
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00066fbc0, 0x1de3810, 0xc00145e700, 0xc001325100)
	/home/couchbase/.cbdepscache/gomodcache/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0xd3
net/http.serverHandler.ServeHTTP(0xc000928000, 0x1de3810, 0xc00145e700, 0xc001325100)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc000cb4aa0, 0x1deed00, 0xc000b35880)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2993 +0x39b
goroutine 1176473 [running]:
github.com/couchbase/query/server.(*Server).serviceRequest.func1(0x1e5a1a8, 0xc001e4a000, 0xc0000b8400)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:958 +0xc6
panic(0x18ac700, 0x2cb9ad0)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/runtime/panic.go:965 +0x1b9
github.com/couchbase/n1fty.(*FTSIndex).buildQueryAndCheckIfSargable(0xc000989380, 0x0, 0x0, 0x0, 0x0, 0x1e16b20, 0xc002b471d0, 0x0, 0x0, 0xc0017d75e0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:685 +0xb56
github.com/couchbase/n1fty.(*FTSIndex).Sargable(0xc000989380, 0x0, 0x0, 0x1e1f9d8, 0xc000b35ac0, 0x1e2eab8, 0xc000b35dc0, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:415 +0x10c
github.com/couchbase/query/planner.(*builder).sargableSearchIndexes(0xc0024403c0, 0xc000a63000, 0xe, 0x100, 0x1e353c8, 0xc0003c22d0, 0xc000c61950, 0xc0017d7a40, 0xc001b63e60, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan_search.go:292 +0x6b6
github.com/couchbase/query/planner.(*builder).buildTermScan(0xc0024403c0, 0xc000ead100, 0xc0009d80f0, 0x1e28d30, 0xc003cdea20, 0xc000a63000, 0xe, 0x100, 0xc001b63e60, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:394 +0x1465
github.com/couchbase/query/planner.(*builder).buildSubsetScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0xc0009d80f0, 0x1e28d30, 0xc003cdea20, 0xc000a63000, 0xe, 0x100, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:291 +0x1f4
github.com/couchbase/query/planner.(*builder).buildPredicateScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0xc0009d80f0, 0x1e28d30, 0xc003cdea20, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:240 +0x38d
github.com/couchbase/query/planner.(*builder).buildScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:163 +0x879
github.com/couchbase/query/planner.(*builder).selectScan(0xc0024403c0, 0x1e11298, 0xc0001c44e0, 0xc000ead100, 0x0, 0x0, 0xc000c62188, 0xaa890a, 0xc000ead680)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:52 +0x3b8
github.com/couchbase/query/planner.(*builder).VisitKeyspaceTerm(0xc0024403c0, 0xc000ead100, 0x203000, 0x203000, 0x0, 0x3000106)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:255 +0x185
github.com/couchbase/query/algebra.(*KeyspaceTerm).Accept(...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_keyspace.go:72
github.com/couchbase/query/planner.(*builder).VisitExpressionTerm(0xc0024403c0, 0xc000b35a80, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:398 +0x6f3
github.com/couchbase/query/algebra.(*ExpressionTerm).Accept(0xc000b35a80, 0x1e0e128, 0xc0024403c0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_expression.go:40 +0x3b
github.com/couchbase/query/planner.(*builder).visitFrom(0xc0024403c0, 0xc0003c2090, 0x0, 0xc0001577e0, 0xc000c62cd0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:176 +0x13a7
github.com/couchbase/query/planner.(*builder).VisitSubselect(0xc0024403c0, 0xc0003c2090, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_sub.go:236 +0xa0a
github.com/couchbase/query/algebra.(*Subselect).Accept(0xc0003c2090, 0x1e0e128, 0xc0024403c0, 0x1e261a0, 0xc000b35c40, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select_sub.go:60 +0x3e
github.com/couchbase/query/planner.(*builder).VisitSelect(0xc0024403c0, 0xc003cde900, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select.go:71 +0x2ca
github.com/couchbase/query/algebra.(*Select).Accept(0xc003cde900, 0x1e15a40, 0xc0024403c0, 0xc002b46c90, 0x8, 0x1a8fd00, 0x1aff660)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select.go:58 +0x3e
github.com/couchbase/query/planner.Build(0x1e02938, 0xc003cde900, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0x1ae0100, 0xc000ead180, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build.go:31 +0x18a
github.com/couchbase/query/planner.BuildPrepared(0x1e02938, 0xc003cde900, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0xc003cd0100, 0xc000ead180, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_prepared.go:19 +0xc5
github.com/couchbase/query/server.(*Server).getPrepared(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000, 0xc000872000, 0x0, 0xc000b359c0, 0x1b9ee5f)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1216 +0x120d
github.com/couchbase/query/server.(*Server).serviceRequest(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1013 +0x225
github.com/couchbase/query/server.(*Server).handleRequest(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000, 0xc0000b8430, 0x9)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:664 +0x6e
github.com/couchbase/query/server.(*Server).ServiceRequest(0xc0000b8400, 0x1e5a1a8, 0xc001e4a000, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:593 +0x79
github.com/couchbase/query/server/http.(*HttpEndpoint).ServeHTTP(0xc0005d2000, 0x1de3810, 0xc00145e700, 0xc001325300)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/http/service_endpoint.go:443 +0x393
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00066fbc0, 0x1de3810, 0xc00145e700, 0xc001325100)
	/home/couchbase/.cbdepscache/gomodcache/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0xd3
net/http.serverHandler.ServeHTTP(0xc000928000, 0x1de3810, 0xc00145e700, 0xc001325100)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc000cb4aa0, 0x1deed00, 0xc000b35880)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2993 +0x39b
2022-06-08T15:45:03.566+00:00 [SEVERE] panic: runtime error: invalid memory address or nil pointer dereference
2022-06-08T15:45:03.566+00:00 [SEVERE] request text: <ud>explain SELECT meta(r).id
FROM `resources` r
WHERE SEARCH(r, $query, {"index":"search-index-v1"})
LIMIT 1;</ud>
2022-06-08T15:45:03.566+00:00 [SEVERE] query context: <ud>default:KWATenantData.transaction</ud>
2022-06-08T15:45:03.566+00:00 [SEVERE] stack: goroutine 1176457 [running]:
github.com/couchbase/query/server.(*Server).serviceRequest.func1(0x1e5a1a8, 0xc00194c000, 0xc0000b8400)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:958 +0xc6
panic(0x18ac700, 0x2cb9ad0)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/runtime/panic.go:965 +0x1b9
github.com/couchbase/n1fty.(*FTSIndex).buildQueryAndCheckIfSargable(0xc000989380, 0x0, 0x0, 0x0, 0x0, 0x1e16b20, 0xc0026929f0, 0x0, 0x0, 0xc0021e2af0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:685 +0xb56
github.com/couchbase/n1fty.(*FTSIndex).Sargable(0xc000989380, 0x0, 0x0, 0x1e1f9d8, 0xc00008b3c0, 0x1e2eab8, 0xc00008b840, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:415 +0x10c
github.com/couchbase/query/planner.(*builder).sargableSearchIndexes(0xc001b8ef00, 0xc000ec3000, 0xe, 0x100, 0x1e353c8, 0xc002b48ab0, 0xc000b918a0, 0xc0021e2cd0, 0xc000ff4ac0, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan_search.go:292 +0x6b6
github.com/couchbase/query/planner.(*builder).buildTermScan(0xc001b8ef00, 0xc000f57600, 0xc00066a1e0, 0x1e28d30, 0xc001ab5920, 0xc000ec3000, 0xe, 0x100, 0xc000ff4ac0, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:394 +0x1465
github.com/couchbase/query/planner.(*builder).buildSubsetScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0xc00066a1e0, 0x1e28d30, 0xc001ab5920, 0xc000ec3000, 0xe, 0x100, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:291 +0x1f4
github.com/couchbase/query/planner.(*builder).buildPredicateScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0xc00066a1e0, 0x1e28d30, 0xc001ab5920, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:240 +0x38d
github.com/couchbase/query/planner.(*builder).buildScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:163 +0x879
github.com/couchbase/query/planner.(*builder).selectScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0x0, 0x0, 0xc000b920d8, 0xaa890a, 0xc000f57780)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:52 +0x3b8
github.com/couchbase/query/planner.(*builder).VisitKeyspaceTerm(0xc001b8ef00, 0xc000f57600, 0x203000, 0x203000, 0x0, 0x4000105)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:255 +0x185
github.com/couchbase/query/algebra.(*KeyspaceTerm).Accept(...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_keyspace.go:72
github.com/couchbase/query/planner.(*builder).VisitExpressionTerm(0xc001b8ef00, 0xc00008b380, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:398 +0x6f3
github.com/couchbase/query/algebra.(*ExpressionTerm).Accept(0xc00008b380, 0x1e0e128, 0xc001b8ef00, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_expression.go:40 +0x3b
github.com/couchbase/query/planner.(*builder).visitFrom(0xc001b8ef00, 0xc002b48990, 0x0, 0xc001806f40, 0xc000b92c20, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:176 +0x13a7
github.com/couchbase/query/planner.(*builder).VisitSubselect(0xc001b8ef00, 0xc002b48990, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_sub.go:236 +0xa0a
github.com/couchbase/query/algebra.(*Subselect).Accept(0xc002b48990, 0x1e0e128, 0xc001b8ef00, 0x1e261a0, 0xc00008b6c0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select_sub.go:60 +0x3e
github.com/couchbase/query/planner.(*builder).VisitSelect(0xc001b8ef00, 0xc001ab57a0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select.go:71 +0x2ca
github.com/couchbase/query/algebra.(*Select).Accept(0xc001ab57a0, 0x1e15a40, 0xc001b8ef00, 0xc000c98400, 0x0, 0xc000b92f80, 0x412578)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select.go:58 +0x3e
github.com/couchbase/query/planner.(*builder).VisitExplain(0xc001b8ef00, 0xc00008b700, 0x1d0, 0x1b097a0, 0x4, 0xc001b8ef00)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_explain.go:17 +0x4e
github.com/couchbase/query/algebra.(*Explain).Accept(0xc00008b700, 0x1e15a40, 0xc001b8ef00, 0xc0026924b0, 0x8, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/explain.go:48 +0x3e
github.com/couchbase/query/planner.Build(0x1e02250, 0xc00008b700, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0x1ae0100, 0xc000f57680, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build.go:31 +0x18a
github.com/couchbase/query/planner.BuildPrepared(0x1e02250, 0xc00008b700, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0xc000080100, 0xc000f57680, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_prepared.go:19 +0xc5
github.com/couchbase/query/server.(*Server).getPrepared(0xc0000b8400, 0x1e5a1a8, 0xc00194c000, 0xc003b20000, 0x0, 0xc0029f7100, 0x1b9ee5f)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1216 +0x120d
github.com/couchbase/query/server.(*Server).serviceRequest(0xc0000b8400, 0x1e5a1a8, 0xc00194c000)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1013 +0x225
github.com/couchbase/query/server.(*Server).handleRequest(0xc0000b8400, 0x1e5a1a8, 0xc00194c000, 0xc0000b8430, 0x9)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:664 +0x6e
github.com/couchbase/query/server.(*Server).ServiceRequest(0xc0000b8400, 0x1e5a1a8, 0xc00194c000, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:593 +0x79
github.com/couchbase/query/server/http.(*HttpEndpoint).ServeHTTP(0xc0005d2000, 0x1de3810, 0xc000a4c7e0, 0xc00034fd00)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/http/service_endpoint.go:443 +0x393
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00066fbc0, 0x1de3810, 0xc000a4c7e0, 0xc00034fb00)
	/home/couchbase/.cbdepscache/gomodcache/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0xd3
net/http.serverHandler.ServeHTTP(0xc000928000, 0x1de3810, 0xc000a4c7e0, 0xc00034fb00)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc0016f4640, 0x1deed00, 0xc0029f6fc0)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2993 +0x39b
goroutine 1176457 [running]:
github.com/couchbase/query/server.(*Server).serviceRequest.func1(0x1e5a1a8, 0xc00194c000, 0xc0000b8400)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:958 +0xc6
panic(0x18ac700, 0x2cb9ad0)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/runtime/panic.go:965 +0x1b9
github.com/couchbase/n1fty.(*FTSIndex).buildQueryAndCheckIfSargable(0xc000989380, 0x0, 0x0, 0x0, 0x0, 0x1e16b20, 0xc0026929f0, 0x0, 0x0, 0xc0021e2af0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:685 +0xb56
github.com/couchbase/n1fty.(*FTSIndex).Sargable(0xc000989380, 0x0, 0x0, 0x1e1f9d8, 0xc00008b3c0, 0x1e2eab8, 0xc00008b840, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/n1fty/index.go:415 +0x10c
github.com/couchbase/query/planner.(*builder).sargableSearchIndexes(0xc001b8ef00, 0xc000ec3000, 0xe, 0x100, 0x1e353c8, 0xc002b48ab0, 0xc000b918a0, 0xc0021e2cd0, 0xc000ff4ac0, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan_search.go:292 +0x6b6
github.com/couchbase/query/planner.(*builder).buildTermScan(0xc001b8ef00, 0xc000f57600, 0xc00066a1e0, 0x1e28d30, 0xc001ab5920, 0xc000ec3000, 0xe, 0x100, 0xc000ff4ac0, 0x1, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:394 +0x1465
github.com/couchbase/query/planner.(*builder).buildSubsetScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0xc00066a1e0, 0x1e28d30, 0xc001ab5920, 0xc000ec3000, 0xe, 0x100, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:291 +0x1f4
github.com/couchbase/query/planner.(*builder).buildPredicateScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0xc00066a1e0, 0x1e28d30, 0xc001ab5920, 0x0, 0x0, 0x0, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:240 +0x38d
github.com/couchbase/query/planner.(*builder).buildScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:163 +0x879
github.com/couchbase/query/planner.(*builder).selectScan(0xc001b8ef00, 0x1e11298, 0xc0001c44e0, 0xc000f57600, 0x0, 0x0, 0xc000b920d8, 0xaa890a, 0xc000f57780)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_scan.go:52 +0x3b8
github.com/couchbase/query/planner.(*builder).VisitKeyspaceTerm(0xc001b8ef00, 0xc000f57600, 0x203000, 0x203000, 0x0, 0x4000105)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:255 +0x185
github.com/couchbase/query/algebra.(*KeyspaceTerm).Accept(...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_keyspace.go:72
github.com/couchbase/query/planner.(*builder).VisitExpressionTerm(0xc001b8ef00, 0xc00008b380, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:398 +0x6f3
github.com/couchbase/query/algebra.(*ExpressionTerm).Accept(0xc00008b380, 0x1e0e128, 0xc001b8ef00, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/from_expression.go:40 +0x3b
github.com/couchbase/query/planner.(*builder).visitFrom(0xc001b8ef00, 0xc002b48990, 0x0, 0xc001806f40, 0xc000b92c20, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_from.go:176 +0x13a7
github.com/couchbase/query/planner.(*builder).VisitSubselect(0xc001b8ef00, 0xc002b48990, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select_sub.go:236 +0xa0a
github.com/couchbase/query/algebra.(*Subselect).Accept(0xc002b48990, 0x1e0e128, 0xc001b8ef00, 0x1e261a0, 0xc00008b6c0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select_sub.go:60 +0x3e
github.com/couchbase/query/planner.(*builder).VisitSelect(0xc001b8ef00, 0xc001ab57a0, 0x0, 0x0, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_select.go:71 +0x2ca
github.com/couchbase/query/algebra.(*Select).Accept(0xc001ab57a0, 0x1e15a40, 0xc001b8ef00, 0xc000c98400, 0x0, 0xc000b92f80, 0x412578)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/select.go:58 +0x3e
github.com/couchbase/query/planner.(*builder).VisitExplain(0xc001b8ef00, 0xc00008b700, 0x1d0, 0x1b097a0, 0x4, 0xc001b8ef00)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_explain.go:17 +0x4e
github.com/couchbase/query/algebra.(*Explain).Accept(0xc00008b700, 0x1e15a40, 0xc001b8ef00, 0xc0026924b0, 0x8, 0x0, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/algebra/explain.go:48 +0x3e
github.com/couchbase/query/planner.Build(0x1e02250, 0xc00008b700, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0x1ae0100, 0xc000f57680, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build.go:31 +0x18a
github.com/couchbase/query/planner.BuildPrepared(0x1e02250, 0xc00008b700, 0x1e151a8, 0xc0001ca1c0, 0x1e154d8, 0xc0004f45b8, 0x1b9b46a, 0x7, 0xc000080100, 0xc000f57680, ...)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/planner/build_prepared.go:19 +0xc5
github.com/couchbase/query/server.(*Server).getPrepared(0xc0000b8400, 0x1e5a1a8, 0xc00194c000, 0xc003b20000, 0x0, 0xc0029f7100, 0x1b9ee5f)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1216 +0x120d
github.com/couchbase/query/server.(*Server).serviceRequest(0xc0000b8400, 0x1e5a1a8, 0xc00194c000)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:1013 +0x225
github.com/couchbase/query/server.(*Server).handleRequest(0xc0000b8400, 0x1e5a1a8, 0xc00194c000, 0xc0000b8430, 0x9)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:664 +0x6e
github.com/couchbase/query/server.(*Server).ServiceRequest(0xc0000b8400, 0x1e5a1a8, 0xc00194c000, 0x0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/server.go:593 +0x79
github.com/couchbase/query/server/http.(*HttpEndpoint).ServeHTTP(0xc0005d2000, 0x1de3810, 0xc000a4c7e0, 0xc00034fd00)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/server/http/service_endpoint.go:443 +0x393
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00066fbc0, 0x1de3810, 0xc000a4c7e0, 0xc00034fb00)
	/home/couchbase/.cbdepscache/gomodcache/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0xd3
net/http.serverHandler.ServeHTTP(0xc000928000, 0x1de3810, 0xc000a4c7e0, 0xc00034fb00)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc0016f4640, 0x1deed00, 0xc0029f6fc0)
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.16.6/go/src/net/http/server.go:2993 +0x39b
2022-06-08T15:45:42.462+00:00 [Info] connected with 2 indexers
2022-06-08T15:45:42.462+00:00 [Info] client stats current counts: current: 16, not current: 0
2022-06-08T15:45:42.488+00:00 [Info] num concurrent scans {0}
2022-06-08T15:45:42.488+00:00 [Info] average scan response {8 ms}

Thanks for reporting this.

I’ve created a ticket - https://issues.couchbase.com/browse/MB-52476
I was able to reproduce and verify the fix, we’ll include this fix in our next release.

This was the commit that introduced this regression - https://review.couchbase.org/c/n1fty/+/169777
So you should look into picking up a build older than 7.1.0 - perhaps 7.0.3 if possible until 7.1.1 becomes available.

@abhinav Thank you for the update that this issue would be resolved in 7.1.1.

@abhinav How can I check the status of the ticket created in this thread - https://issues.couchbase.com/browse/MB-52476.

The ticket seems to be no longer accessible unlike other tickets in the release notes here. Was this ticket reference changed?

Hi @Vinaya_Kumar_B. Turns out we were a little late per the release cycle for 7.1.1.
So the fix is going to be included in 7.1.2 - which is due end of August.

p.s. Loading... should be accessible again.

Thanks for the update @abhinav .