Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec: crash in ordered aggregator #37332

Closed
yuzefovich opened this issue May 6, 2019 · 0 comments · Fixed by #38512
Closed

exec: crash in ordered aggregator #37332

yuzefovich opened this issue May 6, 2019 · 0 comments · Fixed by #38512
Assignees
Labels
A-sql-vec SQL vectorized engine C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@yuzefovich
Copy link
Member

yuzefovich commented May 6, 2019

When trying to import a tpcc fixture on a cluster with vectorized turned on, I ran into this crash:

* ERROR: [n1,client=[::1]:52825,user=root] a SQL panic has occurred while executing "SELECT max(no_o_id) FROM new_order GROUP BY no_d_id, no_w_id ORDER BY no_w_id, no_d_id": runtime error: index out of range
*
*
* ERROR: [n1,client=[::1]:52825,user=root] a panic has occurred!
*
panic while executing 1 statements: SELECT max(_) FROM _ GROUP BY _, _ ORDER BY _, _

goroutine 25553 [running]:
runtime/debug.Stack(0x74f51e0, 0xc008c4fa40, 0xc000000003)
	/usr/local/opt/go/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/cockroachdb/cockroach/pkg/util/log.ReportPanic(0x74f51e0, 0xc008c4fa40, 0xc00022d300, 0x6be3320, 0xc0052cfaa0, 0x1)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/util/log/crash_reporting.go:214 +0xa6
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc008e8e000, 0x74f51e0, 0xc008c4fa40, 0x697a2a0, 0x92f00d0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:714 +0x2dd
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc008e8e000, 0x74f51e0, 0xc008c4fa40)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:434 +0x61
panic(0x697a2a0, 0x92f00d0)
	/usr/local/opt/go/libexec/src/runtime/panic.go:513 +0x1b9
github.com/cockroachdb/cockroach/pkg/sql/exec.OrderedDistinctColsToOperators(0x74c8360, 0xc00805b7e0, 0xc00897e830, 0x2, 0x2, 0xc00897e8a0, 0x2, 0x2, 0x3, 0xc0001350d8, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/exec/distinct.eg.go:37 +0x2a5
github.com/cockroachdb/cockroach/pkg/sql/exec.NewOrderedAggregator(0x74c8360, 0xc00805b7e0, 0xc005675b80, 0x3, 0x3, 0xc00897e890, 0x3, 0x3, 0xc00897e830, 0x2, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/exec/aggregator.go:137 +0x1a9
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.newColOperator(0x74f52a0, 0xc0052cf4d0, 0xc005c92b40, 0xc008faf688, 0xc00805b6e0, 0x1, 0x2, 0x74c8360, 0xc00805b7e0, 0x0, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/column_exec_setup.go:204 +0x3c72
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).setupVectorized(0xc005c92b40, 0x74f52a0, 0xc0052cf4d0, 0xc0052cf500, 0x2)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/column_exec_setup.go:734 +0xa05
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).setup(0xc005c92b40, 0x74f52a0, 0xc0052cf4d0, 0xc005f7d000, 0x2, 0x3b4614559d070d04)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go:495 +0x133
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ServerImpl).setupFlow(0xc0006e70e0, 0x74f52a0, 0xc0051fe750, 0x7528660, 0xc00000db00, 0xc00863ea00, 0xc005f7cff0, 0x74e4b20, 0xc00697e2c0, 0xc008e8e410, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/server.go:463 +0x829
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ServerImpl).SetupLocalSyncFlow(0xc0006e70e0, 0x74f52a0, 0xc0051fe750, 0xc00863ea00, 0xc005f7cff0, 0x74e4b20, 0xc00697e2c0, 0xc008e8e410, 0x0, 0x0, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/server.go:518 +0xe7
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc00075a3c0, 0xc000471ec0, 0xc00759e6c0, 0xc00804e898, 0xc00697e2c0, 0xc008e8e410, 0x0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:242 +0x830
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0xc00075a3c0, 0x74f52a0, 0xc0051fe750, 0xc008e8e410, 0xc000471ec0, 0xc00759e6c0, 0x74f6fa0, 0xc0067d25a0, 0xc00697e2c0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:841 +0x227
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc008e8e000, 0x74f52a0, 0xc0051fe750, 0xc008e8e350, 0x3, 0xec91188, 0xc006946370, 0x1, 0x0, 0x0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:895 +0x283
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc008e8e000, 0x74f52a0, 0xc0051fe750, 0xc008e8e350, 0xec91188, 0xc006946370, 0x0, 0x0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:731 +0x658
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc008e8e000, 0x74f52a0, 0xc0051fe750, 0x74faaa0, 0xc006a0b900, 0xc008e940f3, 0x56, 0x0, 0x0, 0x0, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:412 +0xafe
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc008e8e000, 0x74f52a0, 0xc0051fe750, 0x74faaa0, 0xc006a0b900, 0xc008e940f3, 0x56, 0x0, 0x0, 0x0, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:100 +0x610
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd(0xc008e8e000, 0x74f52a0, 0xc0051fe720, 0x0, 0x0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1200 +0x1ad8
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc008e8e000, 0x74f51e0, 0xc008c4fa40, 0xc0008ac578, 0x5400, 0x15000, 0xc0008ac610, 0xc008ad21f0, 0x0, 0x0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1136 +0x1b4
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc000da2dc0, 0x74f51e0, 0xc008c4fa40, 0xc008e8e000, 0x5400, 0x15000, 0xc0008ac610, 0xc008ad21f0, 0x0, 0x0)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:436 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1(0xc008e721a9, 0xc008a93420, 0x74f51e0, 0xc008c4fa40, 0xc008ad21f0, 0xc000da2dc0, 0xc008e8a000, 0x74f8aa0, 0xc008a93400, 0xc000b51200, ...)
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:580 +0x21f
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync
	/Users/yahoryuzefovich/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:515 +0x17b

Taking a quick look, it seems to me that the problem is that no_d_id and no_w_id are at indices 1 and 2 in the output of scan but are at positions 0 and 1, respectively, at the group by level.
Screen Shot 2019-05-06 at 1 08 47 PM

To reproduce simply run SELECT max(no_o_id) FROM new_order GROUP BY no_d_id, no_w_id ORDER BY no_w_id, no_d_id; (against already present tpcc database) or ./cockroach workload fixtures import tpcc --warehouses=1 --db=tpcc (and that query will get executed as a part of consistency checks).

@yuzefovich yuzefovich added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-vec SQL vectorized engine labels May 6, 2019
craig bot pushed a commit that referenced this issue Jun 27, 2019
38512: exec: fix bug in ordered aggregate planning r=jordanlewis a=jordanlewis

Previously, there was a bug that caused ordered aggregations to not be
planned correctly when some columns weren't present in the grouping
columns.

Fixes #37332.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig craig bot closed this as completed in #38512 Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-vec SQL vectorized engine C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants