pingcap / pingcap/tidb

`COMMIT AND CHAIN` is not compatible with MySQL

Open
#71,059 4 comments 0 reactions 0 assignees View on GitHub
found-by-ai good first issue severity/minor sig/transaction type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

I think this issue is simply because TiDB doesn't implement `COMMIT AND CHAIN`. It's a very simple grammar and task.

### 1. Minimal reproduce step (Required)

1. Run the following in one session:

```sql
CREATE TABLE t(id INT PRIMARY KEY);
SET autocommit=0;
START TRANSACTION;
INSERT INTO t VALUES (1);
COMMIT AND CHAIN;
INSERT INTO t VALUES (2);
ROLLBACK;
SELECT * FROM t ORDER BY id;
```

2. Repeat with `ROLLBACK AND CHAIN` and verify the transaction state after the statement.
3. Optionally test `COMMIT RELEASE` and check whether the connection is released.

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

`COMMIT AND CHAIN` should commit the current transaction and immediately start a new one with the same characteristics. Therefore the insert of `(2)` should be rolled back and the final table should contain only `(1)`. `ROLLBACK AND CHAIN` and `RELEASE` should likewise honor their parsed semantics, or TiDB should reject unsupported syntax.

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

TiDB accepts the modifiers but ignores them. `COMMIT AND CHAIN` behaves as a plain `COMMIT`; with `autocommit=0`, the next statement is not protected by the expected chained transaction, so the subsequent `ROLLBACK` does not undo row 2 and the query returns both rows. `ROLLBACK AND CHAIN` has the same state mismatch, and `COMMIT RELEASE` does not release the session.

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

Reproduced on TiDB v8.5.7 and confirmed on a master build at commit `1dcb34947971e6265e5a2c3610146e0c44978866`.

Contributor guide

Open the contributing guide

Research direction

Start by running the provided CREATE TABLE, transaction, COMMIT AND CHAIN, ROLLBACK AND CHAIN, and COMMIT RELEASE statements against TiDB v8.5.7 or the referenced master build, then trace the handlers for these transaction statements. Done means AND CHAIN starts a new transaction with the expected characteristics, RELEASE releases the session, and the final table contains only row 1 in the first reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql, sql
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.