runtime error: invalid memory address or nil pointer dereference
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
INSERT INTO q_bank_info ( picture, `model`,`type`, correct, wrong_one, wrong_two, wrong_three,`desc`, `rank`, create_time, update_time ) VALUES ( 'aa', 1, 'Animal' ,'Goat', 'Sheep', 'Deer', 'Cow','aa', 1, 1776830157921, 1776830157921 )
The issue is that executing an INSERT statement throws an error. After restarting TiDB, the INSERT operation works normally, but after running for a while, this error occurs again.
### 1. Minimal reproduce step (Required)
CREATE TABLE `q_bank_info` (
`random_id` bigint unsigned NOT NULL /*T![auto_rand] AUTO_RANDOM(3) */,
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`picture` varchar(1024) DEFAULT '' COMMENT 'aa',
`model` int DEFAULT '1' COMMENT 'bb(1:Easy / 2:Medium / 3:Hard / 4:NewUser)',
`type` varchar(32) DEFAULT '' COMMENT 'cc(City / Country)',
`correct` varchar(64) DEFAULT '' COMMENT 'dd',
`wrong_one` varchar(64) DEFAULT '' COMMENT 'e1',
`wrong_two` varchar(64) DEFAULT '' COMMENT 'e2',
`wrong_three` varchar(64) DEFAULT '' COMMENT 'e3',
`accuracy_rate` int DEFAULT '0' COMMENT 'f',
`review_status` int DEFAULT '0' COMMENT 'd(0:d0,1:d1)',
`create_user` varchar(64) DEFAULT '' COMMENT 'c',
`update_user` varchar(64) DEFAULT '' COMMENT 'm',
`desc` varchar(64) DEFAULT '' COMMENT 'de',
`rank` int DEFAULT NULL COMMENT 'r',
`create_time` bigint unsigned NOT NULL DEFAULT '0' COMMENT 'ct',
`update_time` bigint unsigned NOT NULL DEFAULT '0' COMMENT 'mt',
PRIMARY KEY (`random_id`) /*T![clustered_index] CLUSTERED */,
UNIQUE KEY `idx_id` (`id`),
KEY `idx_create_time` (`create_time`),
KEY `idx_type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=2054118775690818866 /*T![auto_rand_base] AUTO_RANDOM_BASE=90002 */ COMMENT='info';
### 2. What did you expect to see? (Required)
### 3. What did you see instead (Required)
[2026/05/14 11:32:40.921 +08:00] [INFO] [conn.go:1184] ["command dispatched failed"] [conn=3854916456] [session_alias=] [connInfo="id:3854916456, addr:10.118.38.83:52753 status:10, collation:utf8_general_ci, user:admindev"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="INSERT INTO q_bank_info ( picture, `model`,`type`, correct, wrong_one, wrong_two, wrong_three,`desc`, `rank`, create_time, update_time ) VALUES ( 'aa', 1, 'Animal' ,'Goat', 'Sheep', 'Deer', 'Cow','aa', 1, 1776830157921, 1776830157921 ) "] [txn_mode=PESSIMISTIC] [timestamp=466283282004967427] [err="runtime error: invalid memory address or nil pointer dereference\ngithub.com/pingcap/errors.AddStack\n\t/root/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20240318064555-6bd07397691f/errors.go:178\ngithub.com/pingcap/errors.Trace\n\t/root/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20240318064555-6bd07397691f/juju_adaptor.go:15\ngithub.com/pingcap/tidb/pkg/util.GetRecoverError\n\t/workspace/source/tidb/pkg/util/util.go:288\ngithub.com/pingcap/tidb/pkg/executor/internal/exec.Next.func1\n\t/workspace/source/tidb/pkg/executor/internal/exec/executor.go:440\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:785\nruntime.panicmem\n\t/usr/local/go/src/runtime/panic.go:262\nruntime.sigpanic\n\t/usr/local/go/src/runtime/signal_unix.go:917\ngithub.com/pingcap/tidb/pkg/table.AllocBatchAutoIncrementValue\n\t/workspace/source/tidb/pkg/table/table.go:517\ngithub.com/pingcap/tidb/pkg/executor.(*InsertValues).lazyAdjustAutoIncrementDatum\n\t/workspace/source/tidb/pkg/executor/insert_common.go:878\ngithub.com/pingcap/tidb/pkg/executor.insertRows\n\t/workspace/source/tidb/pkg/executor/insert_common.go:250\ngithub.com/pingcap/tidb/pkg/executor.(*InsertExec).Next\n\t/workspace/source/tidb/pkg/executor/insert.go:369\ngithub.com/pingcap/tidb/pkg/executor/internal/exec.Next\n\t/workspace/source/tidb/pkg/executor/internal/exec/executor.go:456\ngithub.com/pingcap/tidb/pkg/executor.(*ExecStmt).next\n\t/workspace/source/tidb/pkg/executor/adapter.go:1266\ngithub.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelayExecutor\n\t/workspace/source/tidb/pkg/executor/adapter.go:1015\ngithub.com/pingcap/tidb/pkg/executor.(*ExecStmt).handleNoDelay\n\t/workspace/source/tidb/pkg/executor/adapter.go:848\ngithub.com/pingcap/tidb/pkg/executor.(*ExecStmt).Exec\n\t/workspace/source/tidb/pkg/executor/adapter.go:611\ngithub.com/pingcap/tidb/pkg/session.runStmt\n\t/workspace/source/tidb/pkg/session/session.go:2288\ngithub.com/pingcap/tidb/pkg/session.(*session).ExecuteStmt\n\t/workspace/source/tidb/pkg/session/session.go:2150\ngithub.com/pingcap/tidb/pkg/server.(*TiDBContext).ExecuteStmt\n\t/workspace/source/tidb/pkg/server/driver_tidb.go:291\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).handleStmt\n\t/workspace/source/tidb/pkg/server/conn.go:2026\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).handleQuery\n\t/workspace/source/tidb/pkg/server/conn.go:1779\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).dispatch\n\t/workspace/source/tidb/pkg/server/conn.go:1378\ngithub.com/pingcap/tidb/pkg/server.(*clientConn).Run\n\t/workspace/source/tidb/pkg/server/conn.go:1147\ngithub.com/pingcap/tidb/pkg/server.(*Server).onConn\n\t/workspace/source/tidb/pkg/server/server.go:741\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1700"]
### 4. What is your TiDB version? (Required)
Release Version: v8.5.1
Edition: Community
Git Commit Hash: fea86c8e35ad4a86a5e1160701f99493c2ee547c
Git Branch: HEAD
UTC Build Time: 2025-01-16 07:38:34
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Contributor guide
Assessment
This issue has not been assessed yet.