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

server crash on GROUP BY indexed enum #7307

Closed
morgo opened this issue Aug 7, 2018 · 2 comments · Fixed by #7624
Closed

server crash on GROUP BY indexed enum #7307

morgo opened this issue Aug 7, 2018 · 2 comments · Fixed by #7624
Assignees
Labels
sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@morgo
Copy link
Contributor

morgo commented Aug 7, 2018

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
DROP TABLE IF EXISTS t1;

CREATE TABLE t1 (
 id INT NOT NULL PRIMARY KEY auto_increment,
 b varchar(255) NOT NULL,
 c ENUM('a', 'b', 'c', 'd', 'e'),
 INDEX (c)
);

INSERT INTO t1 VALUES 
 (NULL, REPEAT('b', 255), 'a'),
 (NULL, REPEAT('b', 255), 'b'),
 (NULL, REPEAT('b', 255), 'c'),
 (NULL, REPEAT('b', 255), 'd'),
 (NULL, REPEAT('b', 255), 'e');
 
SELECT c FROM t1 GROUP BY c;

  1. What did you expect to see?

Not crash.

  1. What did you see instead?
2018/08/07 14:43:43.857 conn.go:427: [error] lastCmd SELECT c FROM t1 GROUP BY c, runtime error: slice bounds out of range, goroutine 38207 [running]:
github.com/pingcap/tidb/server.(*clientConn).Run.func1(0xc42087b2b0, 0xc4209f5dff)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:425 +0x10e
panic(0x1155280, 0x1e09700)
        /usr/local/go/src/runtime/panic.go:502 +0x229
github.com/pingcap/tidb/server.(*clientConn).writeResultset.func1(0x0, 0x1445c00, 0xc420b0f2c0, 0xc4209f5bf8, 0xc42087b2b0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:943 +0x325
panic(0x1155280, 0x1e09700)
        /usr/local/go/src/runtime/panic.go:502 +0x229
github.com/pingcap/tidb/util/chunk.Row.getNameValue(0xc420aaeca0, 0x0, 0x0, 0x400, 0x573d1b, 0xc42096602a)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/chunk/row.go:106 +0x126
github.com/pingcap/tidb/util/chunk.Row.GetEnum(0xc420aaeca0, 0x0, 0x0, 0xc4209f5978, 0x1, 0x9)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/chunk/row.go:112 +0x3f
github.com/pingcap/tidb/server.dumpTextRow(0xc420625000, 0x4, 0x400, 0xc421869c80, 0x1, 0x1, 0xc420aaeca0, 0x0, 0x50, 0x121a620, ...)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/util.go:326 +0xcfe
github.com/pingcap/tidb/server.(*clientConn).writeChunks(0xc42087b2b0, 0x7f4649c81130, 0xc420f02d00, 0x1445c00, 0xc420b0f2c0, 0xc400005b00, 0xc42087b2b0, 0x0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:1015 +0x2c5
github.com/pingcap/tidb/server.(*clientConn).writeResultset(0xc42087b2b0, 0x7f4649c81130, 0xc420f02d00, 0x1445c00, 0xc420b0f2c0, 0xc400007c00, 0x0, 0x0, 0x0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:956 +0x1bc
github.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc42087b2b0, 0x7f4649c81130, 0xc420f02d00, 0xc42003c681, 0x1b, 0x0, 0x0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:873 +0x124
github.com/pingcap/tidb/server.(*clientConn).dispatch(0xc42087b2b0, 0xc42003c681, 0x1c, 0x1c, 0x0, 0x0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:612 +0x4f9
github.com/pingcap/tidb/server.(*clientConn).Run(0xc42087b2b0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:470 +0x1be
github.com/pingcap/tidb/server.(*Server).onConn(0xc4207168a0, 0x14478e0, 0xc421869888)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/server.go:324 +0x22b
created by github.com/pingcap/tidb/server.(*Server).Run
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/server.go:264 +0x4dc

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
MySQL [(none)]> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v2.1.0-beta-156-g5e7aa1d
Git Commit Hash: 5e7aa1d97d6459843949ae3587c9b5ac6661bb37
Git Branch: master
UTC Build Time: 2018-08-01 02:49:37
GoVersion: go version go1.10.2 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
1 row in set (0.00 sec)

@ciscoxll ciscoxll added the type/bug The issue is confirmed as a bug. label Aug 7, 2018
@ciscoxll
Copy link
Contributor

ciscoxll commented Aug 7, 2018

@XuHuaiyu PTAL.

@XuHuaiyu
Copy link
Contributor

tidb> desc SELECT c FROM t1 GROUP BY c;
+----------------------+----------+------+---------------------------------------------------------------------+
| id                   | count    | task | operator info                                                       |
+----------------------+----------+------+---------------------------------------------------------------------+
| StreamAgg_8          | 8000.00  | root | group by:test.t1.c, funcs:firstrow(test.t1.c)                       |
| └─IndexReader_16     | 10000.00 | root | index:IndexScan_15                                                  |
|   └─IndexScan_15     | 10000.00 | cop  | table:t1, index:c, range:[NULL,+inf], keep order:true, stats:pseudo |
+----------------------+----------+------+---------------------------------------------------------------------+
3 rows in set (0.00 sec)

This may be caused by the wrong type inferring of firstrow(enum_col),
I'll solve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants