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: integer division causes a panic #38798

Closed
solongordon opened this issue Jul 10, 2019 · 2 comments · Fixed by #38816
Closed

exec: integer division causes a panic #38798

solongordon opened this issue Jul 10, 2019 · 2 comments · Fixed by #38816
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

@solongordon
Copy link
Contributor

Vectorized execution panics when you divide an int column by an int constant, presumably because it thinks the result should be an integer but it should actually be a decimal.

root@127.0.0.1:61735/defaultdb> set experimental_vectorize=on;
SET

Time: 281µs

root@127.0.0.1:61735/defaultdb> create table t (x int);
CREATE TABLE

Time: 2.721ms

root@127.0.0.1:61735/defaultdb> insert into t values (1);
INSERT 1

Time: 2.863ms

root@127.0.0.1:61735/defaultdb> select x/2 from t;
E190710 20:17:30.876509 724 sql/conn_executor.go:713  [n1,client=127.0.0.1:61737,user=root] a SQL panic has occurred while executing "SELECT x / 2 FROM t": interface conversion: coldata.column is []int64, not []apd.Decimal
E190710 20:17:30.876569 724 util/log/crash_reporting.go:207  [n1,client=127.0.0.1:61737,user=root] a panic has occurred!
panic: interface conversion: coldata.column is []int64, not []apd.Decimal [recovered]
	panic: panic while executing 1 statements: SELECT _ / _ FROM _; caused by interface conversion: coldata.column is []int64, not []apd.Decimal

goroutine 724 [running]:
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).closeWrapper(0xc00153b600, 0x77fbde0, 0xc00158d640, 0x6bd5e80, 0xc001175710)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:727 +0x330
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn.func1(0xc00153b600, 0x77fbde0, 0xc00158d640)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:440 +0x61
panic(0x6bd5e80, 0xc001175710)
	/usr/local/Cellar/go/1.12.6/libexec/src/runtime/panic.go:522 +0x1b5
github.com/cockroachdb/cockroach/pkg/sql/exec/coldata.(*memColumn).Decimal(0xc001176dc0, 0x0, 0x785df60, 0xc001176dc0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/exec/coldata/vec.go:226 +0x74
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*materializer).Next(0xc000926e00, 0x59b2eb3, 0xc0011753e0, 0xc001bc2290, 0x5a5a4de)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/materializer.go:166 +0xb87
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.Run(0x77fbea0, 0xc001175200, 0x78079e0, 0xc000926e00, 0x77d87e0, 0xc001430000)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/base.go:171 +0x35
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*ProcessorBase).Run(0xc000926e00, 0x77fbea0, 0xc001175200)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/processors.go:793 +0x92
github.com/cockroachdb/cockroach/pkg/sql/distsqlrun.(*Flow).Run(0xc0001232c0, 0x77fbea0, 0xc001175200, 0x713a620, 0x0, 0x0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsqlrun/flow.go:654 +0x1f2
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).Run(0xc0001e8fc0, 0xc001aca960, 0xc0014ba240, 0xc001bc28b0, 0xc001430000, 0xc00153ba28, 0x0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:295 +0x35c
github.com/cockroachdb/cockroach/pkg/sql.(*DistSQLPlanner).PlanAndRun(0xc0001e8fc0, 0x77fbea0, 0xc001174c90, 0xc00153ba28, 0xc001aca960, 0xc0014ba240, 0x77fdba0, 0xc0014aad80, 0xc001430000)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/distsql_running.go:859 +0x208
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execWithDistSQLEngine(0xc00153b600, 0x77fbea0, 0xc001174c90, 0xc00153b950, 0x3, 0xfa19d18, 0xc0007bf8c0, 0xc001bc2b01, 0x0, 0x0, ...)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:902 +0x370
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).dispatchToExecutionEngine(0xc00153b600, 0x77fbea0, 0xc001174c90, 0xc00153b950, 0xfa19d18, 0xc0007bf8c0, 0x0, 0x0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:734 +0x6e5
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmtInOpenState(0xc00153b600, 0x77fbea0, 0xc001174c90, 0x78013a0, 0xc001118740, 0xc0015531ee, 0x11, 0x0, 0x1, 0x0, ...)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:417 +0xb64
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execStmt(0xc00153b600, 0x77fbea0, 0xc001174c90, 0x78013a0, 0xc001118740, 0xc0015531ee, 0x11, 0x0, 0x1, 0x0, ...)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor_exec.go:99 +0x4ec
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).execCmd(0xc00153b600, 0x77fbde0, 0xc001176780, 0x0, 0x0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1204 +0x1ab0
github.com/cockroachdb/cockroach/pkg/sql.(*connExecutor).run(0xc00153b600, 0x77fbde0, 0xc00158d640, 0xc00010e340, 0x5400, 0x15000, 0xc00010e3d8, 0xc000087160, 0x0, 0x0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:1140 +0x1a3
github.com/cockroachdb/cockroach/pkg/sql.(*Server).ServeConn(0xc0001ddb00, 0x77fbde0, 0xc00158d640, 0xc00153b600, 0x5400, 0x15000, 0xc00010e3d8, 0xc000087160, 0x0, 0x0)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:442 +0xce
github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync.func1(0xc00167c299, 0xc00162e860, 0x77fbde0, 0xc00158d640, 0xc000087160, 0xc0001ddb00, 0xc00176e000, 0x77ff920, 0xc00162e840, 0xc0015674a0, ...)
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:580 +0x21c
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync
	/Users/solon/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:509 +0x17b
@solongordon solongordon 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 Jul 10, 2019
@solongordon solongordon self-assigned this Jul 11, 2019
@solongordon
Copy link
Contributor Author

I think we just need some more column_exec_setup to bail out if types don't match.

@jordanlewis
Copy link
Member

Yeah I think that's probably right. There's a separate missing feature that's kind of related which is mixed-type comparison. This is a mixed-type binary operator. I think eventually we'll need to improve the execgen code to know how to generate all of these - at the moment it's fairly hard coded to a single type.

solongordon added a commit to solongordon/cockroach that referenced this issue Jul 11, 2019
Since our vectorized projection and selection operators currently only
handle homogeneous types, I added logic to the planner which detects
mixed types and errors out.

Fixes cockroachdb#38798

Release note: None
solongordon added a commit to solongordon/cockroach that referenced this issue Jul 11, 2019
Since our vectorized projection and selection operators currently only
handle homogeneous types, I added logic to the planner which detects
mixed types and errors out.

Fixes cockroachdb#38798

Release note: None
craig bot pushed a commit that referenced this issue Jul 11, 2019
38816: exec: bail out on mixed type expressions r=solongordon a=solongordon

Since our vectorized projection and selection operators currently only
handle homogeneous types, I added logic to the planner which detects
mixed types and errors out.

Fixes #38798

Release note: None

Co-authored-by: Solon Gordon <solon@cockroachlabs.com>
@craig craig bot closed this as completed in #38816 Jul 11, 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