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: explain(vec) crashes on query 22 #40484

Closed
jordanlewis opened this issue Sep 4, 2019 · 0 comments · Fixed by #40511
Closed

exec: explain(vec) crashes on query 22 #40484

jordanlewis opened this issue Sep 4, 2019 · 0 comments · Fixed by #40511

Comments

@jordanlewis
Copy link
Member

E190904 19:50:43.723514 1059 sql/conn_executor.go:716  [n1,client=[::1]:51186,user=root] a SQL panic has occurred while executing "EXPLAIN (VEC) SELECT cntrycode, count(*) AS numcust, sum(c_acctbal) AS totacctbal FROM (SELECT substring(c_phone, 1, 2) AS cntrycode, c_acctbal FROM customer WHERE ((substring(c_phone, 1, 2) IN ('13', '31', '23', '29', '30', '18', '17')) AND (c_acctbal > (SELECT avg(c_acctbal) FROM customer WHERE (c_acctbal > 0.00) AND (substring(c_phone, 1, 2) IN ('13', '31', '23', '29', '30', '18', '17'))))) AND (NOT EXISTS (SELECT * FROM orders WHERE o_custkey = c_custkey))) AS custsale GROUP BY cntrycode ORDER BY cntrycode": ReturnType called on TypedExpr with empty typeAnnotation. Was the underlying Expr type-checked before asserting a type of TypedExpr?
E190904 19:50:43.723691 1059 util/log/crash_reporting.go:207  [n1,client=[::1]:51186,user=root] a panic has occurred!
panic: ReturnType called on TypedExpr with empty typeAnnotation. Was the underlying Expr type-checked before asserting a type of TypedExpr? [recovered]
	panic: panic while executing 1 statements: EXPLAIN (VEC) SELECT _, count(*) AS _, sum(_) AS _ FROM (SELECT substring(_, _, _) AS _, _ FROM _ WHERE ((substring(_, _, _) IN (_, _, __more5__)) AND (_ > (SELECT avg(_) FROM _ WHERE (_ > _) AND (substring(_, _, _) IN (_, _, __more5__))))) AND (NOT EXISTS (SELECT * FROM _ WHERE _ = _))) AS _ GROUP BY _ ORDER BY _; caused by ReturnType called on TypedExpr with empty typeAnnotation. Was the underlying Expr type-checked before asserting a type of TypedExpr?

goroutine 1059 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc0063a0000, 0x85a0780, 0xc00330dbc0, 0x78a96c0, 0xc006ded660)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:730 +0x330
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc0063a0000, 0x85a0780, 0xc00330dbc0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:442 +0x61
panic(0x78a96c0, 0xc006ded660)
	/usr/local/Cellar/go/1.12.4/libexec/src/runtime/panic.go:522 +0x1b5
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.typeAnnotation.assertTyped(...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/expr.go:146
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*Subquery).TypeCheck(0xc00847af30, 0xc006e0de00, 0xaf753c0, 0xc0037143a0, 0x1d, 0x1d, 0xc007de9a60)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:1122 +0x186
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.typeCheckOverloadedExprs(0xc006e0de00, 0xaf753c0, 0xc00000c5a0, 0x1d, 0x1d, 0x1, 0xc0084459e0, 0x2, 0x2, 0xc00339fc48, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/overload.go:492 +0x91b
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.typeCheckComparisonOp(0xc006e0de00, 0x2, 0x85c4bc0, 0xc00339fc48, 0x85c5c80, 0xc00847af30, 0x85eecc0, 0xc006cbdd80, 0x85ef1a0, 0xc0030569c0, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:1713 +0x26a
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*ComparisonExpr).TypeCheck(0xc003057040, 0xc006e0de00, 0xaf754c0, 0xc007de9f50, 0x4c8f7f8, 0xaf754c0, 0xaf754c0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:667 +0x2fc
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*ParenExpr).TypeCheck(0xc0084459c0, 0xc006e0de00, 0xaf754c0, 0x85ee4e0, 0xc003057000, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:1059 +0x4b
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.typeCheckAndRequire(0xc006e0de00, 0x85c4dc0, 0xc0084459c0, 0xaf754c0, 0x7c02191, 0xc, 0x85ee4e0, 0xc003057000, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:1463 +0x63
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.typeCheckAndRequireBoolean(...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:1457
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.(*AndExpr).TypeCheck(0xc00847b020, 0xc006e0de00, 0xaf753c0, 0xc00847b020, 0x85c3980, 0xc00847b020, 0x7a09a00)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:301 +0xef
github.com/cockroachdb/cockroach/pkg/sql/sem/tree.TypeCheck(0x85c3980, 0xc00847b020, 0xc006e0de00, 0xaf753c0, 0x85c3980, 0xc00847b020, 0xc0004ad801, 0xd8c06d0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/sem/tree/type_check.go:274 +0x11b
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.processExpression(0x0, 0x0, 0xc00714aa80, 0x166, 0x0, 0x0, 0xc00352b6c0, 0xc006e0de00, 0xc008476d90, 0xc008476d80, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/expr.go:75 +0x15d
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*exprHelper).init(0xc008476d80, 0x0, 0x0, 0xc00714aa80, 0x166, 0x0, 0x0, 0xc003149c00, 0x8, 0x8, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/expr.go:160 +0x292
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ProcOutputHelper).Init(0xc0004bb800, 0xc0084826e8, 0xc003149c00, 0x8, 0x8, 0xc00352b6c0, 0x0, 0x0, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go:109 +0xc15
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.newColBatchScan(0xc0030c9180, 0xc003149000, 0xc0084826e8, 0x1, 0x2, 0x7c43296)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/colbatch_scan.go:113 +0x299
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.newColOperator(0x85a0780, 0xc0030561c0, 0xc0030c9180, 0xc008482600, 0xc008445280, 0x0, 0x2, 0x0, 0x0, 0x0, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/column_exec_setup.go:139 +0x58d6
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*vectorizedFlowCreator).setupFlow(0xc006c5f4a0, 0x85a0780, 0xc0030561c0, 0xc0030c9180, 0xc008482600, 0x4, 0x4, 0xc007deb440, 0x6, 0xb, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/column_exec_setup.go:1494 +0x816
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.SupportsVectorized(0x85a0780, 0xc0030561c0, 0xc0030c9180, 0xc008482600, 0x4, 0x4, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/column_exec_setup.go:1702 +0x503
github.com/cockroachdb/cockroach/pkg/sql.(*explainVecNode).startExec(0xc0038be180, 0x85a0780, 0xc0030561c0, 0xc008476b40, 0xc0063a0358, 0x0, 0xc007deb970)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/explain_vec.go:104 +0x759
github.com/cockroachdb/cockroach/pkg/sql.startExec.func2(0x7c125c0, 0x12, 0x85a2080, 0xc0038be180, 0xc00742f260, 0xc007deb980)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:362 +0x55
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal.func1(0xc0038be2a0, 0x7c125c0, 0x12, 0x85a2080, 0xc0038be180)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:141 +0x5d
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visitInternal(0xc0038be2a0, 0x85a2080, 0xc0038be180, 0x7c125c0, 0x12)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:146 +0x6304
github.com/cockroachdb/cockroach/pkg/sql.(*planVisitor).visit(0xc0038be2a0, 0x85a2080, 0xc0038be180, 0x40691f2, 0x1)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:108 +0x8d
github.com/cockroachdb/cockroach/pkg/sql.walkPlan(...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/walk.go:72
github.com/cockroachdb/cockroach/pkg/sql.startExec(0x85a0780, 0xc0030561c0, 0xc008476b40, 0xc0063a0358, 0x85a2080, 0xc0038be180, 0x0, 0xaffb1a0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan.go:365 +0x286
github.com/cockroachdb/cockroach/pkg/sql.(*planNodeToRowSource).Start(0xc00050ef00, 0x85a0780, 0xc0030561c0, 0xaffb1a0, 0x75c80c0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/plan_node_to_row_source.go:117 +0xd6
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ProcessorBase).Run(0xc00050ef00, 0x85a0780, 0xc0030561c0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go:792 +0x52
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).Run(0xc008429e60, 0x85a0840, 0xc00847ab40, 0x7d7b6c0, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go:584 +0x1ec
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc000354c80, 0xc0038be1e0, 0xc0039b26c0, 0xc007dec760, 0xc0002b5600, 0xc0063a0428, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:337 +0x381
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0xc000354c80, 0x85a0840, 0xc008440ff0, 0xc0063a0428, 0xc0038be1e0, 0xc0039b26c0, 0x85a2080, 0xc0038be180, 0xc0002b5600, 0xc0063a01d8)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:962 +0x20a
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc0063a0000, 0x85a0840, 0xc008440ff0, 0xc0063a0358, 0x3, 0xdc7d8e8, 0xc00372aa68, 0xc007dec900, 0x0, 0x0, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:816 +0x370
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc0063a0000, 0x85a0840, 0xc008440ff0, 0xc0063a0358, 0xdc7d8e8, 0xc00372aa68, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:708 +0x6de
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc0063a0000, 0x85a0840, 0xc008440ff0, 0x85c4980, 0xc008426b70, 0xc00639fc61, 0x20e, 0x0, 0x3, 0x0, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:417 +0xc2f
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc0063a0000, 0x85a0840, 0xc008440ff0, 0x85c4980, 0xc008426b70, 0xc00639fc61, 0x20e, 0x0, 0x3, 0x0, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:98 +0x4ec
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd(0xc0063a0000, 0x85a0780, 0xc003657680, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1238 +0x1aa2
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc0063a0000, 0x85a0780, 0xc00330dbc0, 0xc000138c40, 0x5400, 0x15000, 0xc000138cd8, 0xc0003b9560, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1167 +0x1a3
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc000435400, 0x85a0780, 0xc00330dbc0, 0xc0063a0000, 0x5400, 0x15000, 0xc000138cd8, 0xc0003b9560, 0x0, 0x0)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:444 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1(0xc0062a90f9, 0xc000509780, 0x85a0780, 0xc00330dbc0, 0xc0003b9560, 0xc000435400, 0xc00372a400, 0x85c3800, 0xc000509760, 0xc003acbb00, ...)
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:584 +0x21c
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync
	/Users/jordan/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:513 +0x17b

It looks like we're somehow not preparing the subqueries before running SupportsVectorized on it?

craig bot pushed a commit that referenced this issue Sep 5, 2019
40436: sql: more test fixes for opt-driven foreign keys r=RaduBerinde a=RaduBerinde

Fixing up some expected errors in tests and making sure we don't
buffer the mutation input if we fall back to the legacy path (the
bufferNode is unnecessary and interferes with an interleaved delete
fast path).

Release note: None

40451: testcluster: don't overwrite localities indiscriminately r=andreimatei a=andreimatei

Before this patch, a TestCluster would set localities for all nodes to a
static values. This was overwriting any values set throught the
TestClusterArgs. This patch makes it so that, if any localities are set
in the args, we don't overwrite them.

Release note: None

40485: sql: Fix a bug with ordinal_position in information_schema.columns r=arulajmani a=arulajmani

When a column other than the last is dropped, ordinal_position in
information_schema.columns virtual table no longer matches attnum from
the pg_attribute table. This PR fixes this issue.

Fixes #39787

Release note (bug fix): ordinal_position in information_schema.columns
matches pg_attribute.attnum after a column is dropped.

40511: exec: fix explain(vec) for queries with subqueries r=jordanlewis a=jordanlewis

Also add logic tests that show the explain(vec) plans for all of the
tpch queries.

Closes #40484.

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
Co-authored-by: Arul Ajmani <arula@cockroachlabs.com>
Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig craig bot closed this as completed in 14341a1 Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant