pingcap / pingcap/tidb

inconsistency update when primary key contains timestamp of DST

Open
#60,861 5 comments 0 reactions 0 assignees View on GitHub
affects-6.1 affects-6.5 affects-7.1 affects-7.5 affects-8.1 affects-8.5 impact/inconsistency severity/major sig/execution 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
> create table t(id timestamp primary key, v int);
> set @@time_zone='UTC';
> insert into t values('2025-11-02 09:30:00', 1);
> set @@time_zone='America/Los_Angeles';
> update t set v=v+1;
```

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

Update should success and it should not produce new record.

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

assertion failed when updating:
```sql
TiDB root@127.0.0.1:test> update t set v=v+1;
(8141, 'assertion failed: key: 74800000000000032c5f720419b8048780000000, assertion: Exist, start_ts: 457607176025014273, existing start ts: 0, existing commit ts: 0')
```

If we turn off assertion check, update can success but it produces a new record:

```sql
TiDB root@127.0.0.1:test> select * from t;
+---------------------+---+
| id | v |
+---------------------+---+
| 2025-11-02 01:30:00 | 1 |
+---------------------+---+
1 row in set
Time: 0.004s
TiDB root@127.0.0.1:test> set @@tidb_txn_assertion_level='OFF';
Query OK, 0 rows affected
Time: 0.001s
TiDB root@127.0.0.1:test> update t set v=v+1;
Query OK, 1 row affected
Time: 0.003s
TiDB root@127.0.0.1:test> select * from t;
+---------------------+---+
| id | v |
+---------------------+---+
| 2025-11-02 01:30:00 | 2 |
| 2025-11-02 01:30:00 | 1 |
+---------------------+---+
2 rows in set
Time: 0.003s
```

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

found in master, but it may affects all versions.

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.