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

Tidb panic when colNames2ResultFields #1978

Closed
lilinghai opened this issue May 23, 2021 · 2 comments · Fixed by pingcap/tidb#24862
Closed

Tidb panic when colNames2ResultFields #1978

lilinghai opened this issue May 23, 2021 · 2 comments · Fixed by pingcap/tidb#24862
Labels
affects-5.0 severity/major type/bug The issue is confirmed as a bug.

Comments

@lilinghai
Copy link

The sql

select count(*) as x from table_20_binary_undef as t1 group by t1. `col_int_key_signed` having x not in (select `col_decimal(40, 20)_undef_unsigned` from table_1_latin1_undef as t2 where x = t2. `col_decimal(40, 20)_key_signed`);

The panic log

[2021/05/23 23:01:51.574 +08:00] [ERROR] [conn.go:736] ["connection running loop panic"] [conn=39] [lastSQL="select count(*) as x from table_20_binary_undef as t1 group by t1. `col_int_key_signed` having x not in (select `col_decimal(40, 20)_undef_unsigned` from table_1_latin1_undef as t2 where x = t2. `col_decimal(40, 20)_key_signed`)"] [err="runtime error: index out of range [1] with length 1"] [stack="goroutine 766889 [running]:\ngit.luolix.top/pingcap/tidb/server.(*clientConn).Run.func1(0x40193a0, 0xc003566090, 0xc001ebe900)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:734 +0xee\npanic(0x37ab8a0, 0xc001511800)\n\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\ngit.luolix.top/pingcap/tidb/server.(*clientConn).writeResultset.func1(0xc0011ad100, 0x40193a0, 0xc003322420, 0xc001ebe900)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:1749 +0x4e2\npanic(0x37ab8a0, 0xc001511800)\n\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\ngit.luolix.top/pingcap/tidb/executor.colNames2ResultFields(0xc0021c6fa0, 0xc002b08478, 0x1, 0x1, 0xc004eca6e8, 0x2, 0x2dc0726, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/executor/adapter.go:97 +0x64f\ngit.luolix.top/pingcap/tidb/executor.(*recordSet).Fields(0xc002f9c3c0, 0xc002f9c3c0, 0x2, 0xc0011acee8)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/executor/adapter.go:88 +0xe0\ngit.luolix.top/pingcap/tidb/server.(*tidbResultSet).Columns(0xc002f9c410, 0x40193a0, 0xc003322420, 0xc002f9c460)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/driver_tidb.go:346 +0xa8\ngit.luolix.top/pingcap/tidb/server.(*clientConn).writeChunks(0xc001ebe900, 0x40193a0, 0xc003322420, 0x4039b20, 0xc002f9c410, 0xc00002d000, 0x1e03786, 0x368a200, 0x0)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:1822 +0x708\ngit.luolix.top/pingcap/tidb/server.(*clientConn).writeResultset(0xc001ebe900, 0x40193a0, 0xc003322420, 0x4039b20, 0xc002f9c410, 0x29b00, 0x0, 0x0, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:1762 +0x201\ngit.luolix.top/pingcap/tidb/server.(*clientConn).handleStmt(0xc001ebe900, 0x40193a0, 0xc003322420, 0x4040060, 0xc00089f500, 0x5fb0120, 0x0, 0x0, 0x1, 0x0, ...)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:1656 +0x242\ngit.luolix.top/pingcap/tidb/server.(*clientConn).handleQuery(0xc001ebe900, 0x40192e0, 0xc0030aa1c0, 0xc0028b21e1, 0xe4, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:1503 +0x44f\ngit.luolix.top/pingcap/tidb/server.(*clientConn).dispatch(0xc001ebe900, 0x40192e0, 0xc0030aa1c0, 0xc0028b21e0, 0xe5, 0xe4, 0x0, 0x0)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:1037 +0x6f2\ngit.luolix.top/pingcap/tidb/server.(*clientConn).Run(0xc001ebe900, 0x40193a0, 0xc003566090)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/conn.go:795 +0x293\ngit.luolix.top/pingcap/tidb/server.(*Server).onConn(0xc000b1d5f0, 0xc001ebe900)\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/server.go:477 +0xb1b\ncreated by github.com/pingcap/tidb/server.(*Server).Run\n\t/home/jenkins/agent/workspace/_release5.0-hotfix-tiflash-patch/go/src/github.com/pingcap/tidb/server/server.go:380 +0x8a5\n"]

The plan

+----------------------------------------+---------+-------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                     | estRows | task              | access object | operator info                                                                                                                                                                              |
+----------------------------------------+---------+-------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| TableReader_40                         | 12.80   | root              |               | data:ExchangeSender_39                                                                                                                                                                     |
| └─ExchangeSender_39                    | 12.80   | batchCop[tiflash] |               | ExchangeType: PassThrough                                                                                                                                                                  |
|   └─HashJoin_10                        | 12.80   | batchCop[tiflash] |               | anti semi join, equal:[eq(Column#143, rs.table_1_latin1_undef.col_decimal(40, 20)_key_signed)], other cond:eq(cast(Column#95), rs.table_1_latin1_undef.col_decimal(40, 20)_undef_unsigned) |
|     ├─ExchangeReceiver_38(Build)       | 1.00    | batchCop[tiflash] |               |                                                                                                                                                                                            |
|     │ └─ExchangeSender_37              | 1.00    | batchCop[tiflash] |               | ExchangeType: Broadcast                                                                                                                                                                    |
|     │   └─TableFullScan_36             | 1.00    | batchCop[tiflash] | table:t2      | keep order:false, stats:pseudo                                                                                                                                                             |
|     └─Projection_24(Probe)             | 16.00   | batchCop[tiflash] |               | Column#95, cast(Column#95, decimal(20,0) BINARY)->Column#143                                                                                                                               |
|       └─Projection_32                  | 16.00   | batchCop[tiflash] |               | Column#95                                                                                                                                                                                  |
|         └─HashAgg_33                   | 16.00   | batchCop[tiflash] |               | group by:rs.table_20_binary_undef.col_int_key_signed, funcs:sum(Column#148)->Column#95                                                                                                     |
|           └─ExchangeReceiver_35        | 16.00   | batchCop[tiflash] |               |                                                                                                                                                                                            |
|             └─ExchangeSender_34        | 16.00   | batchCop[tiflash] |               | ExchangeType: HashPartition, Hash Cols: rs.table_20_binary_undef.col_int_key_signed                                                                                                        |
|               └─HashAgg_26             | 16.00   | batchCop[tiflash] |               | group by:rs.table_20_binary_undef.col_int_key_signed, funcs:count(1)->Column#148                                                                                                           |
|                 └─TableFullScan_31     | 20.00   | batchCop[tiflash] | table:t1      | keep order:false, stats:pseudo                                                                                                                                                             |
+----------------------------------------+---------+-------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@lilinghai lilinghai added type/bug The issue is confirmed as a bug. severity/major labels May 23, 2021
@hanfei1991
Copy link
Member

This bug also exists in TiDB. Observing the explain result, aggregation is eliminated unexpectly.

@hanfei1991
Copy link
Member

env: mysql -h172.16.6.27 -uroot -P4019 -D rt

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

Successfully merging a pull request may close this issue.

4 participants