Region epoch not match after retries: Region 1921257903,16210,16535) not in region cache error

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

Original topic: Region epoch not match after retries: Region 1921257903,16210,16535) not in region cache错误

| username: TiDBer_mA8QQuDO

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 5.4.0
[Reproduction Path] When the Java service connects to the database to perform a report statistics function, the execution time is about 1 minute, and it reports the error “Region epoch not match after retries: Region 1921257903,16210,16535) not in region cache.”
[Encountered Problem: Problem Phenomenon and Impact]
[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]

| username: 大飞哥online | Original post link

It might be due to the TiDB Server node’s Region Cache not containing the required Region information, resulting in the inability to correctly process the request.

| username: 大飞哥online | Original post link

Try to clear the Region Cache of the TiDB Server to reload the latest Region information.
You can use the invalidate region <region_id> command to clear the cache of a specific Region, or use the invalidate all regions command to clear the cache of all Regions.
After clearing the cache, when the next query arrives, TiDB will retrieve the latest Region information and update the cache.

| username: h5n1 | Original post link

Use pd-ctl region to check the status of these regions first.

| username: TiDBer_mA8QQuDO | Original post link

Why is there uncontained region information in the TiDB server?

| username: TiDBer_mA8QQuDO | Original post link

I understand the meaning, but this is an issue encountered in the project online. Manual operation might solve this problem for now, but it might occur again in the future. How can we make the database automatically resolve this issue? Is it a bug in the version?

| username: 大飞哥online | Original post link

The information in the Region Cache might be outdated. This can be due to various reasons. First, check if this method can solve the issue.

| username: dba远航 | Original post link

Check if there is a method to refresh the Region Cache.