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

assertion failed on order by items #9331

Closed
zz-jason opened this issue Feb 17, 2019 · 0 comments · Fixed by #9333
Closed

assertion failed on order by items #9331

zz-jason opened this issue Feb 17, 2019 · 0 comments · Fixed by #9333
Assignees
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@zz-jason
Copy link
Member

Bug Report

1. What did you do?

reproduce step:

select 1 as a from dual order by a limit 1;

2. What did you expect to see?

result in mysql:

MySQL(root@localhost:test) > select 1 as a from dual order by a limit 1;
+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

3. What did you see instead?

result in tidb:

TiDB(root@127.0.0.1:test) > select 1 as a from dual order by a limit 1;
ERROR 2013 (HY000): Lost connection to MySQL server during query

the panic stack is:

2019/02/17 10:05:07.983 conn.go:536: [error] lastCmd select 1 as a from dual order by a limit 1, interface conversion: expression.Expression is *expression.Constant, not *expression.Column, goroutine 3560 [running]:
github.com/pingcap/tidb/server.(*clientConn).Run.func1(0xc0003a0750)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:534 +0x10a
panic(0x4ff6cc0, 0xc0005c3920)
        /Users/jianzhang.zj/opt/goroot/src/runtime/panic.go:513 +0x1b9
github.com/pingcap/tidb/server.(*clientConn).writeResultset.func1(0x0, 0x53d0020, 0xc007a05c20, 0xc000707bd0, 0xc0003a0750)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:1086 +0x32f
panic(0x4ff6cc0, 0xc0005c3920)
        /Users/jianzhang.zj/opt/goroot/src/runtime/panic.go:513 +0x1b9
github.com/pingcap/tidb/executor.(*SortExec).buildKeyColumns(0xc00012a8c0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/executor/sort.go:149 +0x1c0
github.com/pingcap/tidb/executor.(*TopNExec).loadChunksUntilTotalLimit(0xc00012a8c0, 0x53c5540, 0xc000847d40, 0xc0006aa050, 0x1)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/executor/sort.go:294 +0x322
github.com/pingcap/tidb/executor.(*TopNExec).Next(0xc00012a8c0, 0x53c5540, 0xc000847d40, 0xc00000e6f8, 0x0, 0x0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/executor/sort.go:255 +0x1e7
github.com/pingcap/tidb/executor.(*ProjectionExec).unParallelExecute(0xc0076342d0, 0x53c5540, 0xc000847d40, 0xc0005c38c0, 0x1, 0x1)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/executor/projection.go:169 +0x9a
github.com/pingcap/tidb/executor.(*ProjectionExec).Next(0xc0076342d0, 0x53c5540, 0xc000847d40, 0xc00000e6f0, 0x0, 0x0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/executor/projection.go:158 +0xe0
github.com/pingcap/tidb/executor.(*recordSet).Next(0xc007a05bd0, 0x53c5540, 0xc000847d40, 0xc00000e6f0, 0x0, 0x0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/executor/adapter.go:104 +0xac
github.com/pingcap/tidb/server.(*tidbResultSet).Next(0xc007a05c20, 0x53c5540, 0xc000847d40, 0xc00000e6f0, 0x4, 0x400)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/driver_tidb.go:365 +0x51
github.com/pingcap/tidb/server.(*clientConn).writeChunks(0xc0003a0750, 0x53c5540, 0xc000847d40, 0x53d0020, 0xc007a05c20, 0xc000007b00, 0xc0003a0750, 0xc0006aa000)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:1135 +0x343
github.com/pingcap/tidb/server.(*clientConn).writeResultset(0xc0003a0750, 0x53c5540, 0xc000847d40, 0x53d0020, 0xc007a05c20, 0xc00000a000, 0x0, 0x0, 0x0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:1099 +0x1bc
github.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc0003a0750, 0x53c5540, 0xc000847d40, 0xc007b0a1b1, 0x2a, 0x0, 0x0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:1016 +0x124
github.com/pingcap/tidb/server.(*clientConn).dispatch(0xc0003a0750, 0xc007b0a1b1, 0x2b, 0x2b, 0x0, 0x0)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:745 +0x59a
github.com/pingcap/tidb/server.(*clientConn).Run(0xc0003a0750)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/conn.go:582 +0x205
github.com/pingcap/tidb/server.(*Server).onConn(0xc000679730, 0x53d27e0, 0xc0005bc200)
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/server.go:405 +0x224
created by github.com/pingcap/tidb/server.(*Server).Run
        /Users/jianzhang.zj/opt/gopath/src/github.com/pingcap/tidb/server/server.go:331 +0x595

the execution plan is:

TiDB(root@127.0.0.1:test) > desc select 1 as a from dual order by a limit 1;
+----------------------+-------+------+--------------------------+
| id                   | count | task | operator info            |
+----------------------+-------+------+--------------------------+
| Projection_6         | 1.00  | root | 1                        |
| └─TopN_7             | 1.00  | root | 1:asc, offset:0, count:1 |
|   └─TableDual_10     | 1.00  | root | rows:1                   |
+----------------------+-------+------+--------------------------+
3 rows in set (0.00 sec)

as you can see, the order by item in TopN_7 is a constant 1.

4. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

TiDB(root@127.0.0.1:test) > select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v3.0.0-beta-64-g6136ab14c
Git Commit Hash: 6136ab14cffcb21e71ffc59bd8df8de1e4af2a69
Git Branch: master
UTC Build Time: 2019-02-17 02:00:47
GoVersion: go version go1.11.2 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
1 row in set (0.01 sec)
@zz-jason zz-jason added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner labels Feb 17, 2019
@zz-jason zz-jason self-assigned this Feb 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant