Error when querying: Region is unavailable

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 查询的时候报错:Region is unavailable

| username: ablewang_xiaobo

[TiDB Usage Environment] Production Environment
[TiDB Version] v4.0.9
[Reproduction Path]
[Encountered Problem: Problem Phenomenon and Impact]

| username: h5n1 | Original post link

  1. Use tiup cluster display to check if any TiKV instances are down.
  2. Use pd-ctl config show to check if the configured number of replicas is >= 3.
| username: tidb菜鸟一只 | Original post link

A TiKV node must have gone down.

| username: ablewang_xiaobo | Original post link

I checked all the nodes in the cluster, and they are normal, with a replica count of 3.
“max-replicas”: 3,

| username: ablewang_xiaobo | Original post link

All TiKV nodes are functioning normally.

| username: h5n1 | Original post link

show table xxx regions to check, then find a region: pd-ctl region to see.

| username: liuis | Original post link

I think the problem is that the tidb-server process is not running. You can check if the tidb-server process is running by using the ps command. If it is not running, you can start it using the systemctl start tidb command.

| username: ablewang_xiaobo | Original post link

I checked all the regions of this table one by one, and they are all normal. The replicas and peers are also normal.

| username: ffeenn | Original post link

Take a look at the monitoring status of the Overview panel and the TiKV panel.

| username: h5n1 | Original post link

Does this table report this error every time it is queried?

| username: ablewang_xiaobo | Original post link

There are no issues with other types of queries, only count type queries report this error.

| username: h5n1 | Original post link

Is there a problem with the region of the index? Check the explain plan to see which index is being used.

| username: h5n1 | Original post link

You can check for regions without a leader or with less than 3 replicas. You can search the forum for similar scripts.

| username: ablewang_xiaobo | Original post link

I checked and found that no indexes were used. How can I see which region the index is in?

| username: ablewang_xiaobo | Original post link

The image you provided is not visible. Please provide the text you need translated.

| username: h5n1 | Original post link

First, follow this to troubleshoot:

| username: ablewang_xiaobo | Original post link

This is very comprehensive, but I checked it against ours, and there are no issues. Strange.

| username: Lucien-卢西恩 | Original post link

Have you tried restarting the TiDB Server? The TiDB Server has a region cache, and if the region has already recovered but the region cache still holds the old region address information, this error might occur.

| username: ablewang_xiaobo | Original post link

I’ve restarted several times, but the problem still exists.

| username: h5n1 | Original post link

Is it still the same table and region?