cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.15k stars 3.81k forks source link

sql: v23.1.15: could not find overload for × aggregate #120044

Open cockroach-sentry opened 8 months ago

cockroach-sentry commented 8 months ago

This issue was auto filed by Sentry. It represents a crash or reported error on a live cluster with telemetry enabled.

Sentry Link: https://cockroach-labs.sentry.io/issues/5044692528/?referrer=webhooks_plugin

Panic Message:

typing.go:172: could not find overload for × aggregate
(1) assertion failure
Wraps: (2) attached stack trace
  -- stack trace:
  | github.com/cockroachdb/cockroach/pkg/sql/opt/memo.FindAggregateOverload
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/memo/typing.go:172
  | github.com/cockroachdb/cockroach/pkg/sql/opt/memo.typeAsAggregate
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/memo/typing.go:329
  | github.com/cockroachdb/cockroach/pkg/sql/opt/memo.InferType
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/memo/typing.go:36
  | github.com/cockroachdb/cockroach/pkg/sql/opt/memo.(*Memo).MemoizeSum
  |     github.com/cockroachdb/cockroach/bazel-out/k8-opt/bin/pkg/sql/opt/memo/expr.og.go:23525
  | github.com/cockroachdb/cockroach/pkg/sql/opt/norm.(*Factory).ConstructSum
  |     github.com/cockroachdb/cockroach/bazel-out/k8-opt/bin/pkg/sql/opt/norm/factory.og.go:21138
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).constructAggregate
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/groupby.go:859
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildAggregation
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/groupby.go:388
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelectClause
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1159
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelectStmtWithoutParens
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1069
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect.func1
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1038
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).processWiths
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/with.go:116
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildSelect
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/select.go:1037
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmt
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:337
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:277
  | github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder.(*Builder).Build
  |     github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder/builder.go:251
  | github.com/cockroachdb/cockroach/pkg/sql.(*optPlanningCtx).buildReusableMemo
  |     github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:441
  | github.com/cockroachdb/cockroach/pkg/sql.(*planner).prepareUsingOptimizer
  |     github.com/cockroachdb/cockroach/pkg/sql/plan_opt.go:169
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).populatePrepared
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:334
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).prepare.func2
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:272
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).prepare
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:277
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).addPreparedStmt
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:116
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execPrepare
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor_prepare.go:77
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2312
  | github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:2103
  | github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn
  |     github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:902
  | github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1
  |     github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:310
  | runtime.goexit
  |     GOROOT/src/runtime/asm_amd64.s:1594
Wraps: (3) could not find overload for × aggregate
Error types: (1) *assert.withAssertionFailure (2) *withstack.withStack (3) *errutil.leafError
-- report composition:
*errutil.leafError: could not find overload for × aggregate
typing.go:172: *withstack.withStack (top exception)
*assert.withAssertionFailure
Stacktrace (expand for inline code snippets): [GOROOT/src/runtime/asm_amd64.s#L1593-L1595](GOROOT/src/runtime/asm_amd64.s#L1593-L1595) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/pgwire/conn.go#L309-L311](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/pgwire/conn.go#L309-L311) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor.go#L901-L903](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor.go#L901-L903) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor.go#L2102-L2104](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor.go#L2102-L2104) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor.go#L2311-L2313](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor.go#L2311-L2313) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L76-L78](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L76-L78) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L115-L117](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L115-L117) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L276-L278](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L276-L278) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L271-L273](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L271-L273) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L333-L335](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/conn_executor_prepare.go#L333-L335) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/plan_opt.go#L168-L170](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/plan_opt.go#L168-L170) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/plan_opt.go#L440-L442](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/plan_opt.go#L440-L442) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/builder.go#L250-L252](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/builder.go#L250-L252) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/builder.go#L276-L278](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/builder.go#L276-L278) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/builder.go#L336-L338](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/builder.go#L336-L338) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1036-L1038](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1036-L1038) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/with.go#L115-L117](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/with.go#L115-L117) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1037-L1039](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1037-L1039) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1068-L1070](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1068-L1070) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1158-L1160](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/select.go#L1158-L1160) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/groupby.go#L387-L389](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/groupby.go#L387-L389) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/groupby.go#L858-L860](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/optbuilder/groupby.go#L858-L860) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/bazel-out/k8-opt/bin/pkg/sql/opt/norm/factory.og.go#L21137-L21139](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/bazel-out/k8-opt/bin/pkg/sql/opt/norm/factory.og.go#L21137-L21139) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/bazel-out/k8-opt/bin/pkg/sql/opt/memo/expr.og.go#L23524-L23526](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/bazel-out/k8-opt/bin/pkg/sql/opt/memo/expr.og.go#L23524-L23526) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/memo/typing.go#L35-L37](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/memo/typing.go#L35-L37) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/memo/typing.go#L328-L330](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/memo/typing.go#L328-L330) [https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/memo/typing.go#L171-L173](https://github.com/cockroachdb/cockroach/blob/9ad399071aba1d361202f9ed6f64aae4f9351f4b/pkg/sql/opt/memo/typing.go#L171-L173)
GOROOT/src/runtime/asm_amd64.s in runtime.goexit at line 1594
pkg/sql/pgwire/conn.go in pkg/sql/pgwire.(*conn).processCommandsAsync.func1 at line 310
pkg/sql/conn_executor.go in pkg/sql.(*Server).ServeConn at line 902
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).run at line 2103
pkg/sql/conn_executor.go in pkg/sql.(*connExecutor).execCmd at line 2312
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).execPrepare at line 77
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).addPreparedStmt at line 116
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).prepare at line 277
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).prepare.func2 at line 272
pkg/sql/conn_executor_prepare.go in pkg/sql.(*connExecutor).populatePrepared at line 334
pkg/sql/plan_opt.go in pkg/sql.(*planner).prepareUsingOptimizer at line 169
pkg/sql/plan_opt.go in pkg/sql.(*optPlanningCtx).buildReusableMemo at line 441
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).Build at line 251
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmtAtRoot at line 277
pkg/sql/opt/optbuilder/builder.go in pkg/sql/opt/optbuilder.(*Builder).buildStmt at line 337
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect at line 1037
pkg/sql/opt/optbuilder/with.go in pkg/sql/opt/optbuilder.(*Builder).processWiths at line 116
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelect.func1 at line 1038
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelectStmtWithoutParens at line 1069
pkg/sql/opt/optbuilder/select.go in pkg/sql/opt/optbuilder.(*Builder).buildSelectClause at line 1159
pkg/sql/opt/optbuilder/groupby.go in pkg/sql/opt/optbuilder.(*Builder).buildAggregation at line 388
pkg/sql/opt/optbuilder/groupby.go in pkg/sql/opt/optbuilder.(*Builder).constructAggregate at line 859
bazel-out/k8-opt/bin/pkg/sql/opt/norm/factory.og.go in pkg/sql/opt/norm.(*Factory).ConstructSum at line 21138
bazel-out/k8-opt/bin/pkg/sql/opt/memo/expr.og.go in pkg/sql/opt/memo.(*Memo).MemoizeSum at line 23525
pkg/sql/opt/memo/typing.go in pkg/sql/opt/memo.InferType at line 36
pkg/sql/opt/memo/typing.go in pkg/sql/opt/memo.typeAsAggregate at line 329
pkg/sql/opt/memo/typing.go in pkg/sql/opt/memo.FindAggregateOverload at line 172

Tags

Tag Value
Command mt start-sql
Environment v23.1.15
Go Version go1.19.13
Platform linux amd64
Distribution CCL
Cockroach Release v23.1.15
Cockroach SHA 9ad399071aba1d361202f9ed6f64aae4f9351f4b
# of CPUs 16
# of Goroutines 276

Jira issue: CRDB-36446

yuzefovich commented 6 months ago

We hit this in #89572. Here is a repro on master:

CREATE TABLE t (
  g  GEOMETRY,
  b BOOL NOT NULL
);

SELECT st_union(t2.g ORDER BY t2.g), t1.b
FROM t AS t1
JOIN t AS t2 ON (t1.b) = (t2.b)
GROUP BY t2.g, t1.b
HAVING every(t2.b);

The problem happens since we try to find an overload for bool_and aggregate with Geometry as the input type.