5001 Query Error

The following Query throws sometimes (when executed 5 times in a row) a 5001 panic error and I don´t know why.

Couchbase Version: 7.2.2

[
  {
    "code": 5001,
    "msg": "Panic: runtime error: invalid memory address or nil pointer dereference"
  }
]
2023-11-15T16:43:12.454+00:00 [SEVERE] panic: runtime error: invalid memory address or nil pointer dereference
2023-11-15T16:43:12.454+00:00 [SEVERE] request text: <ud>PREPARE  MYQUERY</ud>
2023-11-15T16:43:12.454+00:00 [SEVERE] query context: <ud></ud>
2023-11-15T16:43:12.454+00:00 [SEVERE] stack: goroutine 131983011 [running]:
github.com/couchbase/query/execution.(*Context).Recover(0xc00d286dc0, 0xc0032bf900)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/context.go:1221 +0x8a
panic({0x180bd00, 0x2b7bbf0})
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.20.6/go/src/runtime/panic.go:884 +0x213
github.com/couchbase/query/execution.(*base).runConsumer.func1.2()
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:896 +0xb6
panic({0x180bd00, 0x2b7bbf0})
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.20.6/go/src/runtime/panic.go:884 +0x213
github.com/couchbase/query/execution.getOriginalCachedValue({0x0, 0x0}, {0x1d637f8, 0xc0045c3a90}, {0xc01532f478, 0x8}, 0xc005239b38?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/util.go:63 +0x41
github.com/couchbase/query/execution.(*Order).lessThan(0xc0032bf900, {0x0, 0x0}, {0x0, 0x0})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:188 +0x10f
github.com/couchbase/query/execution.(*Order).Less(0xffffffffffffffff?, 0xc005239b68?, 0x7a1791?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:177 +0x51
github.com/couchbase/query/sort.medianOfThree({0x1d2bfe0, 0xc0032bf900}, 0xc00da4ce70?, 0xc0069d7200?, 0xc005239c40?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:76 +0x42
github.com/couchbase/query/sort.doPivot({0x1d2bfe0, 0xc0032bf900}, 0x0, 0x2a)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:99 +0x85
github.com/couchbase/query/sort.quickSort({0x1d2bfe0?, 0xc0032bf900}, 0xc0069d7200?, 0xc005239d10?, 0xc005239d10?, 0x12f98c5?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:183 +0x185
github.com/couchbase/query/sort.Sort({0x1d2bfe0, 0xc0032bf900})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:233 +0x56
github.com/couchbase/query/execution.(*Order).afterItems(0xc0032bf900, 0xc00d286dc0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:113 +0xbe
github.com/couchbase/query/execution.(*base).runConsumer.func1()
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:935 +0x414
github.com/couchbase/query/util.(*Once).Do(0x0?, 0x0?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/util/sync.go:57 +0x31
github.com/couchbase/query/execution.(*base).runConsumer(0x0?, {0x1d34058?, 0xc0032bf900?}, 0x0?, {0x0?, 0x0?})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:865 +0x85
github.com/couchbase/query/execution.(*Order).RunOnce(0x74263e?, 0xc0102afc20?, {0x0?, 0x0?})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:68 +0x73
github.com/couchbase/query/execution.execOp({0x1d55fd8, 0xc0032bf900}, 0xc0004effd0?, {0x0, 0x0})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:527 +0x54
created by github.com/couchbase/query/execution.(*base).fork
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:538 +0x125
goroutine 131983011 [running]:
github.com/couchbase/query/execution.(*Context).Recover(0xc00d286dc0, 0xc0032bf900)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/context.go:1221 +0x8a
panic({0x180bd00, 0x2b7bbf0})
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.20.6/go/src/runtime/panic.go:884 +0x213
github.com/couchbase/query/execution.(*base).runConsumer.func1.2()
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:896 +0xb6
panic({0x180bd00, 0x2b7bbf0})
	/home/couchbase/.cbdepscache/exploded/x86_64/go-1.20.6/go/src/runtime/panic.go:884 +0x213
github.com/couchbase/query/execution.getOriginalCachedValue({0x0, 0x0}, {0x1d637f8, 0xc0045c3a90}, {0xc01532f478, 0x8}, 0xc005239b38?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/util.go:63 +0x41
github.com/couchbase/query/execution.(*Order).lessThan(0xc0032bf900, {0x0, 0x0}, {0x0, 0x0})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:188 +0x10f
github.com/couchbase/query/execution.(*Order).Less(0xffffffffffffffff?, 0xc005239b68?, 0x7a1791?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:177 +0x51
github.com/couchbase/query/sort.medianOfThree({0x1d2bfe0, 0xc0032bf900}, 0xc00da4ce70?, 0xc0069d7200?, 0xc005239c40?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:76 +0x42
github.com/couchbase/query/sort.doPivot({0x1d2bfe0, 0xc0032bf900}, 0x0, 0x2a)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:99 +0x85
github.com/couchbase/query/sort.quickSort({0x1d2bfe0?, 0xc0032bf900}, 0xc0069d7200?, 0xc005239d10?, 0xc005239d10?, 0x12f98c5?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:183 +0x185
github.com/couchbase/query/sort.Sort({0x1d2bfe0, 0xc0032bf900})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/sort/sort.go:233 +0x56
github.com/couchbase/query/execution.(*Order).afterItems(0xc0032bf900, 0xc00d286dc0)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:113 +0xbe
github.com/couchbase/query/execution.(*base).runConsumer.func1()
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:935 +0x414
github.com/couchbase/query/util.(*Once).Do(0x0?, 0x0?)
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/util/sync.go:57 +0x31
github.com/couchbase/query/execution.(*base).runConsumer(0x0?, {0x1d34058?, 0xc0032bf900?}, 0x0?, {0x0?, 0x0?})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:865 +0x85
github.com/couchbase/query/execution.(*Order).RunOnce(0x74263e?, 0xc0102afc20?, {0x0?, 0x0?})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/order.go:68 +0x73
github.com/couchbase/query/execution.execOp({0x1d55fd8, 0xc0032bf900}, 0xc0004effd0?, {0x0, 0x0})
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:527 +0x54
created by github.com/couchbase/query/execution.(*base).fork
	/home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/query/execution/base.go:538 +0x125
SELECT
    m.field1,
    m.field2,
    m.field3,
    m.field4,
    m.field5,
    (SELECT a.*
    FROM m.mySubArray AS a
    ORDER BY a.field1) AS subArrayResult
FROM `{0}` AS b
UNNEST b.myArray AS m
WHERE b.type = $1
ORDER BY m.field1;

There is also an Error in the Couchbase .NET SDK (Version 3.4.13) where the MetaData Object returns Success although the query was aborted.

Can someone please explain why this error occurs and what I can do to resolve it.

The JIRA issues say it is fixed in 7.2.1

https://issues.couchbase.com/issues/?jql=text%20~%20"context.go%3A1221"

This looks like same as MB-58918 Will be fixed in upcoming 7.2.4 release

See if the following workaround works

SELECT m1.*,
    (SELECT a.*
    FROM m1.mySubArray AS a
    ORDER BY a.field1) AS subArrayResult
FROM ( SELECT m.field1, m.field2, m.field3, m.field4, m.field5, m.mySubArray
       FROM `{0}` AS b
       UNNEST b.myArray AS m
       WHERE b.type = $1
       ORDER BY m.field1) AS m1;

It seem to be working now. :slightly_smiling_face:

Thank you.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.