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

nil pointer error #55666

Closed
XuHuaiyu opened this issue Aug 26, 2024 · 2 comments · Fixed by #55732
Closed

nil pointer error #55666

XuHuaiyu opened this issue Aug 26, 2024 · 2 comments · Fixed by #55732
Assignees
Labels
affects-5.1 This bug affects 5.1.x versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. impact/panic severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Aug 26, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists table_abc1;
drop table if exists table_abc2;
drop table if exists table_abc3;
drop table if exists table_abc4;

CREATE TABLE `table_abc1` (
  `column_abc1` varchar(10) DEFAULT NULL,
  `column_abc2` varchar(10) DEFAULT NULL,
  `column_abc3` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE `table_abc3` (
  `column_abc5` varchar(10) DEFAULT NULL,
  `column_abc6` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE `table_abc4` (
  `column_abc3` varchar(10) DEFAULT NULL,
  `column_abc7` varchar(10) DEFAULT NULL,
  `column_abc5` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

INSERT INTO `table_abc1` VALUES ('KTL157','KTL157','KTL157');
INSERT INTO `table_abc3` VALUES ('1000','20240819');
INSERT INTO `table_abc4` VALUES ('KTL157','test','1000');

DELETE FROM table_abc3 t_abc3
WHERE t_abc3.column_abc5 IN (
    SELECT a.column_abc5
    FROM (
        WITH tree_cte1 AS (
            WITH RECURSIVE tree_cte AS (
                SELECT t.column_abc1, t.column_abc2, t.column_abc3, 0 AS lv
                FROM table_abc1 t
                WHERE t.column_abc1 IN ('KTL157', 'KTL159')
                UNION ALL
                SELECT t.column_abc1, t.column_abc2, t.column_abc3, tcte.lv + 1
                FROM table_abc1 t
                JOIN tree_cte tcte ON t.column_abc1 = tcte.column_abc2
                WHERE tcte.lv <= 1
            )
            SELECT * FROM tree_cte
        )
        SELECT  e.column_abc5
        FROM (
            SELECT DISTINCT * FROM tree_cte1
        ) aa
        LEFT JOIN table_abc4 e ON e.column_abc3 = aa.column_abc3
    ) a
);

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

no error

3. What did you see instead (Required)

ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference
[2024/08/26 18:36:20.488 +08:00] [INFO] [conn.go:1183] ["command dispatched failed"] [conn=872415234] [session_alias=] [connInfo="id:872415234, addr:127.0.0.1:56448 status:10, collation:utf8mb4_0900_ai_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="DELETE FROM table_abc3 t_abc3 WHERE t_abc3.column_abc5 IN (     SELECT a.column_abc5     FROM (         WITH tree_cte1 AS (             WITH RECURSIVE tree_cte AS (                 SELECT t.column_abc1, t.column_abc2, t.column_abc3, 0 AS lv                 FROM table_abc1 t                 WHERE t.column_abc1 IN ('KTL157', 'KTL159')                 UNION ALL                 SELECT t.column_abc1, t.column_abc2, t.column_abc3, tcte.lv + 1                 FROM table_abc1 t                 JOIN tree_cte tcte ON t.column_abc1 = tcte.column_abc2                 WHERE tcte.lv <= 1             )             SELECT * FROM tree_cte         )         SELECT  e.column_abc5         FROM (             SELECT DISTINCT * FROM tree_cte1         ) aa         LEFT JOIN table_abc4 e ON e.column_abc3 = aa.column_abc3     ) a )"] [txn_mode=PESSIMISTIC] [timestamp=452111520359514125] [err="runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/errors.AddStack\n\t/home/xhy/Development/Golang/GOPATH/pkg/mod/github.com/pingcap/[email protected]/errors.go:178\ngithub.com/pingcap/errors.Trace\n\t/home/xhy/Development/Golang/GOPATH/pkg/mod/github.com/pingcap/[email protected]/juju_adaptor.go:15\ngithub.com/pingcap/tidb/pkg/util.GetRecoverError\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/util/util.go:288\ngithub.com/pingcap/tidb/pkg/executor/internal/exec.Next.func1\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/internal/exec/executor.go:435\nruntime.gopanic\n\t/home/xhy/.gvm/gos/go1.21.5/src/runtime/panic.go:914\nruntime.panicmem\n\t/home/xhy/.gvm/gos/go1.21.5/src/runtime/panic.go:261\nruntime.sigpanic\n\t/home/xhy/.gvm/gos/go1.21.5/src/runtime/signal_unix.go:861\ngithub.com/pingcap/tidb/pkg/executor.(*DeleteExec).deleteOneRow\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/delete.go:70\ngithub.com/pingcap/tidb/pkg/executor.(*DeleteExec).deleteSingleTableByChunk\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/delete.go:140\ngithub.com/pingcap/tidb/pkg/executor.(*DeleteExec).Next\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/delete.go:62\ngithub.com/pingcap/tidb/pkg/executor/internal/exec.Next\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/internal/exec/executor.go:451\ngithub.com/pingcap/tidb/pkg/executor.(*ExecStmt).next\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/adapter.go:1252\ngithub.com/pingc
ap/tidb/pkg/executor.(*ExecStmt).handleNoDelayExecutor\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/adapter.go:1001\ngithub.com/pingcap/tidb/pkg/executor.(*
ExecStmt).handleNoDelay\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/executor/adapter.go:834\ngithub.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec\n\t/home/xhy/Deve
lopment/github.com/pingcap/tidb/pkg/executor/adapter.go:598\ngithub.com/pingcap/tidb/pkg/session.runStmt\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/session/session
.go:2284\ngithub.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/session/session.go:2145\ngithub.com/pingcap/tidb/pk
g/server.(*TiDBContext).ExecuteStmt\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/server/driver_tidb.go:291\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).handleSt
mt\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/server/conn.go:2056\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).handleQuery\n\t/home/xhy/Development/github.com
/pingcap/tidb/pkg/server/conn.go:1810\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).dispatch\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/server/conn.go:1384\ngi
thub.com/pingcap/tidb/pkg/server.(*clientConn).Run\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/server/conn.go:1146\ngithub.com/pingcap/tidb/pkg/server.(*Server).onC
onn\n\t/home/xhy/Development/github.com/pingcap/tidb/pkg/server/server.go:741\nruntime.goexit\n\t/home/xhy/.gvm/gos/go1.21.5/src/runtime/asm_amd64.s:1650"]
[2024/08/26 18:36:37.383 +08:00] [INFO] [domain.go:3156] ["instance plan eviction"] [detail="memory usage is below the soft limit, currentTot: 0, softLimit: 104857600"] [num
_evicted=0] [time_spent=850ns]

4. What is your TiDB version? (Required)

nightly

@XuHuaiyu XuHuaiyu added the type/bug The issue is confirmed as a bug. label Aug 26, 2024
@pingcap pingcap deleted a comment Aug 26, 2024
@pingcap pingcap deleted a comment Aug 26, 2024
@jebter jebter added affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. labels Aug 27, 2024
@XuHuaiyu XuHuaiyu added sig/planner SIG: Planner and removed sig/execution SIG execution labels Aug 28, 2024
@XuHuaiyu
Copy link
Contributor Author

XuHuaiyu commented Aug 28, 2024

img_v3_02e6_459b1991-32ef-4fbb-a267-b69d2938836g

img_v3_02e6_aadd7e01-2d5a-4281-9018-a4def052248g

@XuHuaiyu
Copy link
Contributor Author

+-------------------------------------+----------+-----------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                  | estRows  | task      | access object | operator info                                                                                                                                                                       |
+-------------------------------------+----------+-----------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Delete_45                           | N/A      | root      |               | N/A                                                                                                                                                                                 |
| └─HashJoin_66                       | 45.00    | root      |               | inner join, equal:[eq(test.table_abc3.column_abc5, test.table_abc4.column_abc5)]                                                                                                    |
|   ├─HashAgg_71(Build)               | 36.00    | root      |               | group by:test.table_abc4.column_abc5, funcs:firstrow(test.table_abc4.column_abc5)->test.table_abc4.column_abc5                                                                      |
|   │ └─HashJoin_73                   | 36.00    | root      |               | inner join, equal:[eq(test.table_abc1.column_abc3, test.table_abc4.column_abc3)]                                                                                                    |
|   │   ├─HashAgg_74(Build)           | 28.80    | root      |               | group by:Column#69, test.table_abc1.column_abc1, test.table_abc1.column_abc2, test.table_abc1.column_abc3, funcs:firstrow(test.table_abc1.column_abc3)->test.table_abc1.column_abc3 |
|   │   │ └─Selection_75              | 32.00    | root      |               | not(isnull(test.table_abc1.column_abc3))                                                                                                                                            |
|   │   │   └─CTEFullScan_76          | 40.00    | root      | CTE:tree_cte  | data:CTE_2                                                                                                                                                                          |
|   │   └─TableReader_79(Probe)       | 9980.01  | root      |               | data:Selection_78                                                                                                                                                                   |
|   │     └─Selection_78              | 9980.01  | cop[tikv] |               | not(isnull(test.table_abc4.column_abc3)), not(isnull(test.table_abc4.column_abc5))                                                                                                  |
|   │       └─TableFullScan_77        | 10000.00 | cop[tikv] | table:e       | keep order:false, stats:pseudo                                                                                                                                                      |
|   └─TableReader_70(Probe)           | 9990.00  | root      |               | data:Selection_69                                                                                                                                                                   |
|     └─Selection_69                  | 9990.00  | cop[tikv] |               | not(isnull(test.table_abc3.column_abc5))                                                                                                                                            |
|       └─TableFullScan_68            | 10000.00 | cop[tikv] | table:t_abc3  | keep order:false, stats:pseudo                                                                                                                                                      |
| CTE_2                               | 40.00    | root      |               | Recursive CTE                                                                                                                                                                       |
| ├─Projection_47(Seed Part)          | 20.00    | root      |               | test.table_abc1.column_abc1, test.table_abc1.column_abc2, test.table_abc1.column_abc3, 0->Column#52                                                                                 |
| │ └─TableReader_50                  | 20.00    | root      |               | data:Selection_49                                                                                                                                                                   |
| │   └─Selection_49                  | 20.00    | cop[tikv] |               | in(test.table_abc1.column_abc1, "KTL157", "KTL159")                                                                                                                                 |
| │     └─TableFullScan_48            | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo                                                                                                                                                      |
| └─Projection_54(Recursive Part)     | 20.00    | root      |               | test.table_abc1.column_abc1, test.table_abc1.column_abc2, test.table_abc1.column_abc3, cast(plus(Column#60, 1), bigint(1) BINARY)->Column#65                                        |
|   └─Projection_55                   | 20.00    | root      |               | test.table_abc1.column_abc1, test.table_abc1.column_abc2, test.table_abc1.column_abc3, Column#60                                                                                    |
|     └─HashJoin_57                   | 20.00    | root      |               | inner join, equal:[eq(test.table_abc1.column_abc2, test.table_abc1.column_abc1)]                                                                                                    |
|       ├─Selection_58(Build)         | 16.00    | root      |               | le(Column#60, 1), not(isnull(test.table_abc1.column_abc2))                                                                                                                          |
|       │ └─CTETable_59               | 20.00    | root      |               | Scan on CTE_2                                                                                                                                                                       |
|       └─TableReader_62(Probe)       | 9990.00  | root      |               | data:Selection_61                                                                                                                                                                   |
|         └─Selection_61              | 9990.00  | cop[tikv] |               | not(isnull(test.table_abc1.column_abc1))                                                                                                                                            |
|           └─TableFullScan_60        | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo                                                                                                                                                      |
+-------------------------------------+----------+-----------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

@time-and-fate time-and-fate self-assigned this Aug 29, 2024
@time-and-fate time-and-fate added affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-5.1 This bug affects 5.1.x versions. and removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.1 This bug affects 5.1.x versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. impact/panic severity/major 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.

3 participants