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

executor: (*Column).GetString panic #23887

Closed
fzhedu opened this issue Apr 7, 2021 · 7 comments · Fixed by #24024 or #24369
Closed

executor: (*Column).GetString panic #23887

fzhedu opened this issue Apr 7, 2021 · 7 comments · Fixed by #24024 or #24369
Assignees
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@fzhedu
Copy link
Contributor

fzhedu commented Apr 7, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql -h172.16.5.85 -P52324 -uroot -D subquery_agg10000

SELECT  ( 3, 5 )  IN ( SELECT   SUBQUERY1_t1 . `col_decimal_30_10_not_null` AS SUBQUERY1_field1 , SUBQUERY1_t2 . `col_int_not_null_key` AS SUBQUERY1_field2 FROM `V` AS SUBQUERY1_t1 RIGHT  JOIN `H` AS SUBQUERY1_t2 ON (SUBQUERY1_t2 . `col_varchar_key` = SUBQUERY1_t1 . `col_varchar_64_not_null`  ) WHERE ( SUBQUERY1_t1 . `col_varchar_64` <= 'y' AND SUBQUERY1_t1 . `col_char_64` <> 't' ) GROUP BY SUBQUERY1_field1 , SUBQUERY1_field2  ) AS field1 FROM `J` AS table1 LEFT  JOIN `W` AS table2 ON (table2 . `col_decimal_40_not_null_key` = table1 . `col_decimal_30_10_key`  ) WHERE  ( 'f', 'e' ) NOT IN ( SELECT   SUBQUERY2_t1 . `col_varchar_64` AS SUBQUERY2_field1 , min( SUBQUERY2_t1 . `col_char_64` ) AS SUBQUERY2_field2 FROM `Z` AS SUBQUERY2_t1 LEFT OUTER JOIN `B` AS SUBQUERY2_t2 ON (SUBQUERY2_t2 . `col_char_64` = SUBQUERY2_t1 . `col_varchar_key`  )  GROUP BY SUBQUERY2_field1  ) AND ( table2 . `col_char_64` != 'w' OR table1 . `col_int_not_null` IS  NULL )   ;
SELECT  ( 'l', 'f' )  IN ( SELECT DISTINCT  SUBQUERY1_t2 . `col_varchar_64_not_null` AS SUBQUERY1_field1 , max( SUBQUERY1_t1 . `col_varchar_64` ) AS SUBQUERY1_field2 FROM `T` AS SUBQUERY1_t1 LEFT OUTER JOIN `O` AS SUBQUERY1_t2 ON (SUBQUERY1_t2 . `col_varchar_64` = SUBQUERY1_t1 . `col_varchar_key`  )  GROUP BY SUBQUERY1_field1  ) AS field1 FROM `DD` AS table1 RIGHT OUTER JOIN `X` AS table2 INNER JOIN `P` AS table3 ON (table3 . `col_int_key` = table2 . `col_decimal_not_null_key`  ) ON (table3 . `col_decimal` = table2 . `col_decimal_40_key`  ) WHERE  table1 . `col_char_64_not_null` > ANY ( SELECT   SUBQUERY2_t1 . `col_char_64_not_null` AS SUBQUERY2_field1 FROM `I` AS SUBQUERY2_t1 RIGHT  JOIN `J` AS SUBQUERY2_t2 ON (SUBQUERY2_t2 . `col_decimal_40_key` = SUBQUERY2_t1 . `col_tinyint_not_null`  ) WHERE SUBQUERY2_t1 . `col_int_not_null` <> table3 . `col_decimal_40` AND SUBQUERY2_t1 . `col_int` != 6 ) OR table1 . `pk` = 224 OR (  ( SELECT   COUNT(  SUBQUERY3_t1 . `col_varchar_64` ) AS SUBQUERY3_field1 FROM `B` AS SUBQUERY3_t1 INNER JOIN `W` AS SUBQUERY3_t2 ON (SUBQUERY3_t2 . `pk` = SUBQUERY3_t1 . `col_decimal_key`  )  ) IS  NULL AND table1 . `col_int` >= table2 . `col_decimal_key` )   ;
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
ERROR 1105 (HY000) at line 1: runtime error: index out of range [9] with length 9
SELECT  ( 8, 2 )  IN ( SELECT   SUBQUERY1_t1 . `col_decimal_30_10` AS SUBQUERY1_field1 , max( SUBQUERY1_t1 . `col_decimal_40_key` ) AS SUBQUERY1_field2 FROM `O` AS SUBQUERY1_t1 RIGHT OUTER JOIN ( `U` AS SUBQUERY1_t2 RIGHT  JOIN `X` AS SUBQUERY1_t3 ON (SUBQUERY1_t3 . `col_varchar_key` = SUBQUERY1_t2 . `col_varchar_64_not_null`  )) ON (SUBQUERY1_t3 . `col_char_64` = SUBQUERY1_t2 . `col_varchar_key`  )  GROUP BY SUBQUERY1_field1  ) AS field1 FROM `G` AS table1 LEFT OUTER JOIN `CC` AS table2 ON (table2 . `col_varchar_64_not_null` = table1 . `col_varchar_key`  ) WHERE  NOT EXISTS ( SELECT   SUBQUERY2_t1 . `col_varchar_64` AS SUBQUERY2_field1 FROM `H` AS SUBQUERY2_t1 LEFT  JOIN `F` AS SUBQUERY2_t2 ON (SUBQUERY2_t2 . `col_bigint` = SUBQUERY2_t1 . `col_decimal_40_key`  ) WHERE ( SUBQUERY2_t1 . `col_decimal_40` <> 9 AND SUBQUERY2_t2 . `col_varchar_64_not_null` = 'o' ) GROUP BY SUBQUERY2_field1 ) AND table2 . `col_char_64` >= 't'   ;

2. What did you expect to see? (Required)

ok

3. What did you see instead (Required)

2021/04/07 15:16:23.293 +08:00] [ERROR] [misc.go:90] ["panic in the recoverable goroutine"] [r={}] ["stack trace"="github.com/pingcap/tidb/util.WithRecovery.func1\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/misc.go:92\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:679\nruntime.goPanicIndex\n\t/usr/local/go/src/runtime/panic.go:75\ngithub.com/pingcap/tidb/util/chunk.(*Column).GetString\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/chunk/column.go:528\ngithub.com/pingcap/tidb/util/chunk.Row.GetString\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/chunk/row.go:72\ngithub.com/pingcap/tidb/expression.(*Column).EvalString\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/column.go:397\ngithub.com/pingcap/tidb/expression.CompareStringWithCollationInfo\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/builtin_compare.go:2657\ngithub.com/pingcap/tidb/expression.(*builtinEQStringSig).evalInt\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/builtin_compare.go:2135\ngithub.com/pingcap/tidb/expression.(*ScalarFunction).EvalInt\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/scalar_function.go:378\ngithub.com/pingcap/tidb/expression.(*ScalarFunction).Eval\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/scalar_function.go:345\ngithub.com/pingcap/tidb/expression.EvalBool\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/expression.go:235\ngithub.com/pingcap/tidb/executor.(*antiSemiJoiner).tryToMatchInners\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/joiner.go:449\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).joinMatchedProbeSideRow2Chunk\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:527\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).join2Chunk\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:596\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).runJoinWorker\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:457\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchAndProbeHashTable.func2\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:339\ngithub.com/pingcap/tidb/util.WithRecovery\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/misc.go:95"]
[ERROR] [misc.go:90] ["panic in the recoverable goroutine"] [r={}] ["stack trace"="github.com/pingcap/tidb/util.WithRecovery.func1\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/misc.go:92\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:679\nruntime.goPanicIndex\n\t/usr/local/go/src/runtime/panic.go:75\ngithub.com/pingcap/tidb/util/chunk.(*Column).GetString\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/chunk/column.go:528\ngithub.com/pingcap/tidb/util/chunk.Row.GetString\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/chunk/row.go:72\ngithub.com/pingcap/tidb/expression.(*Column).EvalString\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/column.go:397\ngithub.com/pingcap/tidb/expression.CompareStringWithCollationInfo\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/builtin_compare.go:2657\ngithub.com/pingcap/tidb/expression.(*builtinEQStringSig).evalInt\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/builtin_compare.go:2135\ngithub.com/pingcap/tidb/expression.(*ScalarFunction).EvalInt\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/scalar_function.go:378\ngithub.com/pingcap/tidb/expression.(*ScalarFunction).Eval\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/scalar_function.go:345\ngithub.com/pingcap/tidb/expression.EvalBool\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/expression/expression.go:235\ngithub.com/pingcap/tidb/executor.(*leftOuterSemiJoiner).tryToMatchInners\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/joiner.go:519\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).joinMatchedProbeSideRow2Chunk\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:527\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).join2Chunk\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:596\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).runJoinWorker\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:457\ngithub.com/pingcap/tidb/executor.(*HashJoinExec).fetchAndProbeHashTable.func2\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/executor/join.go:339\ngithub.com/pingcap/tidb/util.WithRecovery\n\t/home/jenkins/agent/workspace/tidb_master/go/src/github.com/pingcap/tidb/util/misc.go:95"]

4. What is your TiDB version? (Required)

master of nightly

@fzhedu fzhedu added the type/bug The issue is confirmed as a bug. label Apr 7, 2021
@jebter jebter added the sig/execution SIG execution label Apr 9, 2021
@wshwsh12
Copy link
Contributor

/assign guo-shaoge

@ti-chi-bot
Copy link
Member

@wshwsh12: GitHub didn't allow me to assign the following users: guo-shaoge.

Note that only pingcap members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign guo-shaoge

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@guo-shaoge
Copy link
Collaborator

/assign

@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Apr 13, 2021

Column index of subquery_agg10000.z.col_char_64 in HashJoin_17 is 0, it means when eval col_char_64, we will use first column in output chunk of TableReader_55 as input.

There should be zero column in output chunk of TableReader_55(because other cond in HashJoin_17 doesn't use any row of TableReader_55). But actually there are 4 column in the output of TableReader_55.

So root cause of this panic is HashJoin_19's output is wrong(MPP hash join).

mysql> explain SELECT    count(*) FROM      `j`  LEFT JOIN `w` ON        (w.`col_decimal_40_not_null_key` = j . `col_decimal_30_10_key` ) WHERE     ('e') NOT IN           (SELECT `col_char_64` FROM  `z`) AND       (w . `col_char_64` != 'w');
+------------------------------------------+---------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------+
| id                                       | estRows | task         | access object | operator info                                                                                                      |
+------------------------------------------+---------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------+
| HashAgg_13                               | 1.00    | root         |               | funcs:count(1)->Column#196                                                                                         |
| └─HashJoin_17                            | 14.64   | root         |               | CARTESIAN anti semi join, other cond:eq("e", subquery_agg10000.z.col_char_64)                                      |
|   ├─TableReader_77(Build)                | 500.00  | root         |               | data:TableFullScan_76                                                                                              |
|   │ └─TableFullScan_76                   | 500.00  | cop[tiflash] | table:Z       | keep order:false, stats:pseudo                                                                                     |
|   └─TableReader_55(Probe)                | 18.31   | root         |               | data:ExchangeSender_54                                                                                             |
|     └─ExchangeSender_54                  | 18.31   | cop[tiflash] |               | ExchangeType: PassThrough                                                                                          |
|       └─HashJoin_19                      | 18.31   | cop[tiflash] |               | inner join, equal:[eq(subquery_agg10000.w.col_decimal_40_not_null_key, subquery_agg10000.j.col_decimal_30_10_key)] |
|         ├─ExchangeReceiver_51(Build)     | 14.64   | cop[tiflash] |               |                                                                                                                    |
|         │ └─ExchangeSender_50            | 14.64   | cop[tiflash] |               | ExchangeType: Broadcast                                                                                            |
|         │   └─Selection_49               | 14.64   | cop[tiflash] |               | ne(subquery_agg10000.w.col_char_64, "w")                                                                           |
|         │     └─TableFullScan_48         | 22.00   | cop[tiflash] | table:W       | keep order:false, stats:pseudo                                                                                     |
|         └─Selection_53(Probe)            | 66.93   | cop[tiflash] |               | not(isnull(subquery_agg10000.j.col_decimal_30_10_key))                                                             |
|           └─TableFullScan_52             | 67.00   | cop[tiflash] | table:J       | keep order:false, stats:pseudo                                                                                     |
+------------------------------------------+---------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------+
13 rows in set (0.00 sec)

@guo-shaoge
Copy link
Collaborator

same reason as here

@XuHuaiyu XuHuaiyu added sig/planner SIG: Planner and removed sig/execution SIG execution labels Apr 16, 2021
@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Apr 27, 2021

This fix caused a case regression here.
So I reverted this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
8 participants