pingcap / pingcap/tidb

Inconsistent stale read check result with prepared `START TRANSACTION`

Open
#40,720 1 comment 0 reactions 0 assignees View on GitHub
severity/minor sig/transaction type/bug
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)

```sql
PREPARE stmt1 FROM 'START TRANSACTION READ ONLY AS OF TIMESTAMP NOW() - INTERVAL 5 SECOND';
EXECUTE stmt1;
EXECUTE stmt1;
```

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

If not using prepared statement, the second start succeeds:

```sql
START TRANSACTION READ ONLY AS OF TIMESTAMP NOW() - INTERVAL 5 SECOND;
START TRANSACTION READ ONLY AS OF TIMESTAMP NOW() - INTERVAL 5 SECOND;
```

So, I expect it to also succeed when using prepared statement.

### 3. What did you see instead (Required)

The second `EXECUTE` raises `ERROR 1105 (HY000): only support read-only statement during read-only staleness transactions`.

### 4. What is your TiDB version? (Required)

6.5

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.