pingcap / pingcap/tidb

A simple query can cause "ERROR 9005 (HY000): Region is unavailable"

Open
#67,816 4 comments 0 reactions 0 assignees View on GitHub
affects-8.5 component/tikv contribution may-affects-7.1 may-affects-7.5 may-affects-8.1 severity/critical type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Hi, I found a crash in TiDB. Executing the following PoC causes `ERROR 9005 (HY000): Region is unavailable`. After this error occurs, any subsequent query on the affected tables will also fail with the same Region is unavailable error.

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t0(c0 DOUBLE, c1 INTEGER, c2 CHAR(1));
CREATE TABLE t1 LIKE t0;
INSERT INTO t0 VALUES (0.3, 0, '᜝');
CREATE INDEX i0 ON t1(c2);
SELECT * FROM t0 JOIN t1 ON t0.c0 < t1.c0 WHERE (CAST(CAST(t0.c2 AS CHAR) AS BINARY)) LIKE (CAST(false AS DATE)) AND t0.c0 >= t1.c0 HAVING CASE '1' WHEN CAST(t0.c1 AS BINARY) THEN -1 ELSE t1.c1 END;
ERROR 9005 (HY000): Region is unavailable
```

### 2. What did you expect to see? (Required)
```sql
SELECT * FROM t0 JOIN t1 ON t0.c0 < t1.c0 WHERE (CAST(CAST(t0.c2 AS CHAR) AS BINARY)) LIKE (CAST(false AS DATE)) AND t0.c0 >= t1.c0 HAVING CASE '1' WHEN CAST(t0.c1 AS BINARY) THEN -1 ELSE t1.c1 END; -- empty set
```

### 3. What did you see instead (Required)
```sql
SELECT * FROM t0 JOIN t1 ON t0.c0 < t1.c0 WHERE (CAST(CAST(t0.c2 AS CHAR) AS BINARY)) LIKE (CAST(false AS DATE)) AND t0.c0 >= t1.c0 HAVING CASE '1' WHEN CAST(t0.c1 AS BINARY) THEN -1 ELSE t1.c1 END;
ERROR 9005 (HY000): Region is unavailable
```
### 4. What is your TiDB version? (Required)

| Release Version: v8.5.6
Edition: Community
Git Commit Hash: ae18096e023780bb56bfce33698abec0d4640d0a
Git Branch: HEAD
UTC Build Time: 2026-04-14 07:15:36
GoVersion: go1.25.8
Race Enabled: false
Check Table Before Drop: false
Store: tikv |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.