Run `select * from t tablesample regions()` report `Error 1105 (HY000): PD returned no region`
- 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)
Found by ci
https://do.pingcap.net/jenkins/blue/organizations/jenkins/pingcap%2Ftidb%2Fperiodics_integration_test/detail/periodics_integration_test/2879/pipeline/
```
time="2024-04-25T10:35:29+08:00" level=error msg="run test [executor/sample] err: sql:select * from t tablesample regions() order by a;: run \"select * from t tablesample regions() order by a;\" at line 140 err Error 1105 (HY000): PD returned no region, startKey: \"748000000000002DFE5F72\", endKey: \"748000000000002DFE5F73\", limit: 128, encode_start_key: \"748000000000002DFFFE5F720000000000FA\", encode_end_key: \"748000000000002DFFFE5F730000000000FA\""
```
### 2. What did you expect to see? (Required)
No error return
### 3. What did you see instead (Required)
report `Error 1105 (HY000): PD returned no region`
### 4. What is your TiDB version? (Required)
Some logs
https://do.pingcap.net/jenkins/blue/organizations/jenkins/pingcap%2Ftidb%2Fperiodics_integration_test/detail/periodics_integration_test/2879/artifacts
PD log
[pd1.log](https://github.com/pingcap/tidb/files/15124507/pd1.log)
Tidb log
```
[2024/04/25 10:22:48.011 +08:00] [INFO] [ddl_worker.go:1174] ["run DDL job"] [worker="worker 4, tp general"] [category=ddl] [jobID=11776] [conn=3741320114] [category=ddl] [job="ID:11776, Type:create table, State:queueing, SchemaState:none, SchemaID:11724, TableID:11773, RowCount:0, ArgLen:0, start time: 2024-04-25 10:22:47.966 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/04/25 10:22:48.030 +08:00] [INFO] [ddl_worker.go:732] ["finish DDL job"] [worker="worker 4, tp general"] [category=ddl] [jobID=11776] [conn=3741320114] [job="ID:11776, Type:create table, State:synced, SchemaState:public, SchemaID:11724, TableID:11773, RowCount:0, ArgLen:0, start time: 2024-04-25 10:22:47.966 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/04/25 10:22:48.033 +08:00] [INFO] [ddl.go:1287] ["DDL job is finished"] [category=ddl] [jobID=11776]
[2024/04/25 10:22:48.033 +08:00] [INFO] [callback.go:140] ["performing DDL change, must reload"]
[2024/04/25 10:22:48.033 +08:00] [INFO] [split_region.go:85] ["split batch regions request"] ["split key count"=1] ["batch count"=1] ["first batch, region ID"=14] ["first split key"=748000000000002dfe]
[2024/04/25 10:22:48.034 +08:00] [INFO] [split_region.go:187] ["batch split regions complete"] ["batch region ID"=14] ["first at"=748000000000002dfe] ["first new region left"="{Id:9246 StartKey:748000000000002dfffa5f728000000000ff0001f40000000000fa EndKey:748000000000002dfffe00000000000000f8 RegionEpoch:{ConfVer:1 Version:4473} Peers:[id:9247 store_id:1 ] EncryptionMeta: IsInFlashback:false FlashbackStartTs:0}"] ["new region count"=1]
[2024/04/25 10:22:48.034 +08:00] [INFO] [split_region.go:236] ["split regions complete"] ["region count"=1] ["region IDs"="[9246]"]
[2024/04/25 10:22:48.034 +08:00] [INFO] [split_region.go:85] ["split batch regions request"] ["split key count"=1] ["batch count"=1] ["first batch, region ID"=14] ["first split key"=748000000000002dff]
[2024/04/25 10:22:48.035 +08:00] [INFO] [region_request.go:1686] ["send request meet region error without retry"] [req-ts=0] [req-type=SplitRegion] [region="{ region id: 14, ver: 4472, confVer: 1 }"] [replica-read-type=leader] [stale-read=false] [request-sender="{rpcError:, replicaSelector: replicaSelectorV2{replicaReadType: leader, attempts: 1, cacheRegionIsValid: false, replicaStatus: [peer: 15, store: 1, isEpochStale: false, attempts: 1, replica-epoch: 0, store-epoch: 0, store-state: resolved, store-liveness-state: reachable]}}"] [retry-times=0] [total-backoff-ms=0] [total-backoff-times=0] [max-exec-timeout-ms=30000] [total-region-errors=15-epoch_not_match:1]
[2024/04/25 10:22:48.035 +08:00] [INFO] [domain.go:280] ["diff load InfoSchema success"] [currentSchemaVersion=15585] [neededSchemaVersion=15586] ["start time"=633.815µs] [gotSchemaVersion=15586] [phyTblIDs="[11773,11774,11775]"] [actionTypes="[3,3,3]"] [diffTypes="[\"create table\"]"]
[2024/04/25 10:22:48.036 +08:00] [WARN] [prewrite.go:382] ["1pc failed and fallbacks to normal commit procedure"] [conn=3741320114] [session_alias=] [startTS=449317900914786314]
[2024/04/25 10:22:48.038 +08:00] [INFO] [split_region.go:187] ["batch split regions complete"] ["batch region ID"=14] ["first at"=748000000000002dff] ["first new region left"="{Id:9248 StartKey:748000000000002dfffe00000000000000f8 EndKey:748000000000002dffff00000000000000f8 RegionEpoch:{ConfVer:1 Version:4474} Peers:[id:9249 store_id:1 ] EncryptionMeta: IsInFlashback:false FlashbackStartTs:0}"] ["new region count"=1]
[2024/04/25 10:22:48.038 +08:00] [INFO] [split_region.go:236] ["split regions complete"] ["region count"=1] ["region IDs"="[9248]"]
[2024/04/25 10:22:48.038 +08:00] [INFO] [conn.go:1151] ["command dispatched failed"] [conn=3741320114] [session_alias=] [connInfo="id:3741320114, addr:127.0.0.1:43654 status:10, collation:utf8mb4_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="select * from t tablesample regions() order by a;"] [txn_mode=PESSIMISTIC] [timestamp=449317900914786317] [err="PD returned no region, startKey: \"748000000000002DFE5F72\", endKey: \"748000000000002DFE5F73\", limit: 128, encode_start_key: \"748000000000002DFFFE5F720000000000FA\", encode_end_key: \"748000000000002DFFFE5F730000000000FA\"\ngithub.com/tikv/client-go/v2/internal/locate.(*RegionCache).scanRegions\n\t/go/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240424052342-0229f4077f0c/internal/locate/region_cache.go:1976\ngithub.com/tikv/client-go/v2/internal/locate.(*RegionCache).BatchLoadRegionsWithKeyRange\n\t/go/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240424052342-0229f4077f0c/internal/locate/region_cache.go:1556\ngithub.com/tikv/client-go/v2/internal/locate.(*RegionCache).LoadRegionsInKeyRange\n\t/go/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240424052342-0229f4077f0c/internal/locate/region_cache.go:1535\ngithub.com/pingcap/tidb/pkg/executor.splitIntoMultiRanges\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:228\ngithub.com/pingcap/tidb/pkg/executor.(*tableRegionSampler).splitTableRanges\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:209\ngithub.com/pingcap/tidb/pkg/executor.(*tableRegionSampler).initRanges\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:145\ngithub.com/pingcap/tidb/pkg/executor.(*tableRegionSampler).writeChunk\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:120\ngithub.com/pingcap/tidb/pkg/executor.(*TableSampleExecutor).Next\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:64\ngithub.com/pingcap/tidb/pkg/executor/internal/exec.Next\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/internal/exec/executor.go:403\ngithub.com/pingcap/tidb/pkg/executor.(*UnionExec).resultPuller\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/executor.go:1887\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650\ngithub.com/pingcap/errors.AddStack\n\t/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20240318064555-6bd07397691f/errors.go:178\ngithub.com/pingcap/errors.Trace\n\t/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20240318064555-6bd07397691f/juju_adaptor.go:15\ngithub.com/pingcap/tidb/pkg/executor.splitIntoMultiRanges\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:230\ngithub.com/pingcap/tidb/pkg/executor.(*tableRegionSampler).splitTableRanges\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:209\ngithub.com/pingcap/tidb/pkg/executor.(*tableRegionSampler).initRanges\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:145\ngithub.com/pingcap/tidb/pkg/executor.(*tableRegionSampler).writeChunk\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:120\ngithub.com/pingcap/tidb/pkg/executor.(*TableSampleExecutor).Next\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/sample.go:64\ngithub.com/pingcap/tidb/pkg/executor/internal/exec.Next\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/internal/exec/executor.go:403\ngithub.com/pingcap/tidb/pkg/executor.(*UnionExec).resultPuller\n\t/home/jenkins/agent/workspace/pingcap/tidb/periodics_integration_test/tidb/pkg/executor/executor.go:1887\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650"]
[2024/04/25 10:22:48.039 +08:00] [INFO] [session.go:3928] ["CRUCIAL OPERATION"] [conn=3741320124] [schemaVersion=15586] [cur_db=test] [sql="drop database `executor__sample`"] [user=root@%]
[2024/04/25 10:22:48.050 +08:00] [INFO] [ddl_worker.go:255] ["add DDL jobs"] [category=ddl] ["batch count"=1] [jobs="ID:11777, Type:drop schema, State:queueing, SchemaState:public, SchemaID:11724, TableID:0, RowCount:0, ArgLen:1, start time: 2024-04-25 10:22:48.016 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false; "] [table=true]
[2024/04/25 10:22:48.050 +08:00] [INFO] [ddl.go:1182] ["start DDL job"] [category=ddl] [job="ID:11777, Type:drop schema, State:queueing, SchemaState:public, SchemaID:11724, TableID:0, RowCount:0, ArgLen:1, start time: 2024-04-25 10:22:48.016 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"] [query="drop database `executor__sample`"]
[2024/04/25 10:22:48.074 +08:00] [INFO] [ddl_worker.go:1174] ["run DDL job"] [worker="worker 4, tp general"] [category=ddl] [jobID=11777] [conn=3741320124] [category=ddl] [job="ID:11777, Type:drop schema, State:queueing, SchemaState:public, SchemaID:11724, TableID:0, RowCount:0, ArgLen:0, start time: 2024-04-25 10:22:48.016 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/04/25 10:22:48.092 +08:00] [INFO] [ddl_worker.go:1174] ["run DDL job"] [worker="worker 4, tp general"] [category=ddl] [jobID=11777] [conn=3741320124] [category=ddl] [job="ID:11777, Type:drop schema, State:running, SchemaState:write only, SchemaID:11724, TableID:0, RowCount:0, ArgLen:0, start time: 2024-04-25 10:22:48.016 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/04/25 10:22:48.111 +08:00] [INFO] [ddl_worker.go:1174] ["run DDL job"] [worker="worker 4, tp general"] [category=ddl] [jobID=11777] [conn=3741320124] [category=ddl] [job="ID:11777, Type:drop schema, State:running, SchemaState:delete only, SchemaID:11724, TableID:0, RowCount:0, ArgLen:0, start time: 2024-04-25 10:22:48.016 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/04/25 10:22:48.130 +08:00] [INFO] [delete_range.go:447] ["insert into delete-range table"] [category=ddl] [jobID=11777] [tableIDs="[11740,11770,11773,11774,11775]"] [comment="drop schema: table IDs"]
[2024/04/25 10:22:48.132 +08:00] [INFO] [delete_range.go:112] ["add job into delete-range table"] [category=ddl] [jobID=11777] [jobType="drop schema"]
[2024/04/25 10:22:48.132 +08:00] [INFO] [ddl_worker.go:732] ["finish DDL job"] [worker="worker 4, tp general"] [category=ddl] [jobID=11777] [conn=3741320124] [job="ID:11777, Type:drop schema, State:synced, SchemaState:none, SchemaID:11724, TableID:0, RowCount:0, ArgLen:1, start time: 2024-04-25 10:22:48.016 +0800 CST, Err:, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
[2024/04/25 10:22:48.135 +08:00] [INFO] [ddl.go:1287] ["DDL job is finished"] [category=ddl] [jobID=11777]
[2024/04/25 10:22:48.135 +08:00] [INFO] [callback.go:140] ["performing DDL change, must reload"]
```
Contributor guide
Assessment
This issue has not been assessed yet.