pingcap / pingcap/tidb

`information_schema.TIDB_INDEXES` gives stale results when using `START TRANSACTION`

Open
#39,390 2 comments 0 reactions 0 assignees View on GitHub
sig/sql-infra sig/transaction type/question
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

When transaction is used, the `information_schema.TIDB_INDEXES` returns stale results. It behaves differently than mysql 5.7.

### 1. Minimal reproduce step (Required)

1. Create an empty table.

```sql
CREATE TABLE t1 (c1 INT);
```

2. Add index and count the number of indexes in 2 different sessions.
- In session 1, `CREATE INDEX idx_t1_c1 ON t1(c1);`
- In session 2, `SELECT count(*) AS indexes FROM information_schema.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1';`

| time | session1 | session 2 |
| ----- | ------------------- | ----------------------------- |
| t1 | | begin |
| t2 | create index start | |
| t3 | create index end | |
| t4 | | count table indexes |

### 2. What did you expect to see? (Required)
1 from session 2.

### 3. What did you see instead (Required)
0 from session 2.

### 4. What is your TiDB version? (Required)
Release Version: v6.1.2
Edition: Community
Git Commit Hash: 5d2030e1d19629b71811c3f14514bad7ed63261a
Git Branch: heads/refs/tags/v6.1.2
UTC Build Time: 2022-10-18 08:04:48
GoVersion: go1.18.5
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

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.