pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
37.03k stars 5.82k forks source link

undesirable duplicate error in binlog downstream when amend txn enabled #25367

Closed lysu closed 3 years ago

lysu commented 3 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

setup a cluster with:

upstream: pd/tikv/tidb/pump/drainer downstream: tikdb with unistore

enable binlog by set[binlog] enable = true enable pessimistic by set global tidb_txn_mode='pessimistic'; enable amend by set global tidb_enable_amend_pessimistic_txn = 1;

create init table:

create table t(c1 varchar(500), c2 int);

start 3 sessions:

---session1--- begin;
---session2--- begin;
---session1--- insert into t select 'abc', 10;
---session2--- insert into t select 'abc', 20;
---session3--- create unique index uk1 on t(c1);
---session1--- commit;
---session2--- update t set c1 = concat(c1, 'p') where c2 = 20;
---session2--- commit;

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

both upstream and downstream should be

+-------+------+
| c1    | c2   |
+-------+------+
| abc   |   10 |
| abc12 |   20 |
+-------+------+

3. What did you see instead (Required)

downstream only:

+------+------+
| c1   | c2   |
+------+------+
| abc  |   10 |
+------+------+

miss c2:20 record

and drainer exit with:

[2021/06/11 15:09:21.882 +08:00] [ERROR] [main.go:69] ["start drainer server failed"] [error="Error 1062: Duplicate entry 'abc' for key 'uk1'"] [errorVerbose="Error 1062: Duplicate entry 'abc' for key 'uk1'

4. What is your TiDB version? (Required)

6.11's master tidb/tikv/pd/binlog

lysu commented 3 years ago

duplicated to https://github.com/pingcap/tidb/issues/23306, it's a known issue for amend txn

zimulala commented 3 years ago

Related to #20909.