`load data` failed because of `truncate table`
- 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!
### 1. Minimal reproduce step (Required)
1. Create table `t`
2. Use `load data` Import some data, the data should be large which requires some time to execute. At the same time open another session, execute `truncate table t`
### 2. What did you expect to see? (Required)
No error
### 3. What did you see instead (Required)
The load data sql failed
```
mysql> load data local infile '/Users/fanzhou/Downloads/testCSV/merged.csv' into table sbtest1;
ERROR 1105 (HY000): runtime error: index out of range [0] with length 0
```
tidb.log: panic
```
[2026/03/19 14:24:04.279 +08:00] [ERROR] [load_data.go:529] ["commitWork panicked"] [conn=150994950] [session_alias=] [r="runtime error: index out of range [0] with length 0"] [stack="github.com/pingcap/tidb/pkg/executor.(*commitWorker).commitWork.func1\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:531\nruntime.gopanic\n\t/usr/local/go1.21/src/runtime/panic.go:914\nruntime.goPanicIndex\n\t/usr/local/go1.21/src/runtime/panic.go:114\ngithub.com/pingcap/tidb/pkg/executor.getKeysNeedCheckOneRow\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/batch_checker.go:122\ngithub.com/pingcap/tidb/pkg/executor.getKeysNeedCheck\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/batch_checker.go:89\ngithub.com/pingcap/tidb/pkg/executor.(*InsertValues).batchCheckAndInsert\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/insert_common.go:1190\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).checkAndInsertOneBatch\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:605\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).commitOneTask\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:574\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).commitWork\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:558\ngithub.com/pingcap/tidb/pkg/executor.(*LoadDataWorker).load.func2\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:192\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/Users/pingcap/go/pkg/mod/golang.org/x/sync@v0.5.0/errgroup/errgroup.go:75"]
[2026/03/19 14:24:05.100 +08:00] [INFO] [conn.go:1131] ["command dispatched failed"] [conn=150994950] [session_alias=] [connInfo="id:150994950, addr:127.0.0.1:55119 status:10, collation:utf8mb4_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="load data local infile '/Users/fanzhou/Downloads/testCSV/merged.csv' into table sbtest1"] [txn_mode=PESSIMISTIC] [timestamp=465017619659358210] [err="runtime error: index out of range [0] with length 0\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).commitWork.func1\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:532\nruntime.gopanic\n\t/usr/local/go1.21/src/runtime/panic.go:914\nruntime.goPanicIndex\n\t/usr/local/go1.21/src/runtime/panic.go:114\ngithub.com/pingcap/tidb/pkg/executor.getKeysNeedCheckOneRow\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/batch_checker.go:122\ngithub.com/pingcap/tidb/pkg/executor.getKeysNeedCheck\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/batch_checker.go:89\ngithub.com/pingcap/tidb/pkg/executor.(*InsertValues).batchCheckAndInsert\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/insert_common.go:1190\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).checkAndInsertOneBatch\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:605\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).commitOneTask\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:574\ngithub.com/pingcap/tidb/pkg/executor.(*commitWorker).commitWork\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:558\ngithub.com/pingcap/tidb/pkg/executor.(*LoadDataWorker).load.func2\n\t/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-k5m6z-build-binaries/source/tidb/pkg/executor/load_data.go:192\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/Users/pingcap/go/pkg/mod/golang.org/x/sync@v0.5.0/errgroup/errgroup.go:75\nruntime.goexit\n\t/usr/local/go1.21/src/runtime/asm_arm64.s:1197"]
```
tidb.log: a lot of `table doesn't exist`
```
[2026/03/19 14:24:04.571 +08:00] [ERROR] [load_data.go:509] ["failed to get row"] [conn=150994950] [session_alias=] [error="[meta:1146]table doesn't exist"]
[2026/03/19 14:24:04.571 +08:00] [ERROR] [load_data.go:509] ["failed to get row"] [conn=150994950] [session_alias=] [error="[meta:1146]table doesn't exist"]
...
```
### 4. What is your TiDB version? (Required)
v7.5.6
Contributor guide
Assessment
This issue has not been assessed yet.