Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Inconsistency when meet TiDB "amend + add column default 'xxx'" #3929

Closed
Tracked by #4048
maxshuang opened this issue Dec 16, 2021 · 1 comment · Fixed by #3930
Closed
Tracked by #4048

Data Inconsistency when meet TiDB "amend + add column default 'xxx'" #3929

maxshuang opened this issue Dec 16, 2021 · 1 comment · Fixed by #3930
Assignees
Labels
affects-4.0 affects-5.0 affects-5.1 affects-5.2 affects-5.3 area/ticdc Issues or PRs related to TiCDC. severity/major subject/correctness Denotes an issue or pull request is related to correctness. type/bug The issue is confirmed as a bug.

Comments

@maxshuang
Copy link
Contributor

What did you do?

  1. Setup upstream TIDB and downstream MySQL
  2. Create a changfeed
  3. Prepare and run two sessions in TiDB as follows:

Session 1:

mysql> show variables like "%amend%";
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| tidb_enable_amend_pessimistic_txn | ON    |
+-----------------------------------+-------+
1 row in set (0.01 sec)

mysql> create table t2(id int primary key);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into t2 values(1);
Query OK, 1 row affected (0.00 sec)

mysql> select * from t2;
+----+
| id |
+----+
|  1 |
+----+
1 row in set (0.00 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t2 values(2);
Query OK, 1 row affected (0.00 sec)

// HOLD here until session2 commit DDL

mysql> commit;
Query OK, 0 rows affected (0.01 sec)

Session2:

mysql> select * from t2;
+----+
| id |
+----+
|  1 |
+----+
1 row in set (0.05 sec)

// Exec DDL before session1 commit

mysql> alter table t2 add column c1 datetime default "2020-10-10 10:10:10";
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

// Before Session1 commit, we do select 

mysql> select * from t2;
+----+---------------------+
| id | c1                  |
+----+---------------------+
|  1 | 2020-10-10 10:10:10 |
+----+---------------------+
1 row in set (0.06 sec)

// After Session1 commit, we do select

mysql> select * from t2;
+----+---------------------+
| id | c1                  |
+----+---------------------+
|  1 | 2020-10-10 10:10:10 |
|  2 | 2020-10-10 10:10:10 |
+----+---------------------+
2 rows in set (0.06 sec)
  1. Select from MySQL
mysql> select * from t2;
+----+---------------------+
| id | c1                  |
+----+---------------------+
|  1 | 2020-10-10 10:10:10 |
|  2 | NULL |
+----+---------------------+

Root Cause
https://github.com/pingcap/ticdc/blob/master/cdc/entry/mounter.go#L509
image

Before PR #3846, this bug still exists
image

What did you expect to see?

data consistence

What did you see instead?

data inconsistency

Versions of the cluster

Upstream TiDB cluster version (execute SELECT tidb_version(); in a MySQL client):

all

TiCDC version (execute cdc version):

all
@maxshuang maxshuang added type/bug The issue is confirmed as a bug. area/ticdc Issues or PRs related to TiCDC. labels Dec 16, 2021
@maxshuang maxshuang added the subject/correctness Denotes an issue or pull request is related to correctness. label Dec 16, 2021
@maxshuang maxshuang self-assigned this Dec 16, 2021
@maxshuang maxshuang changed the title Data Inconsistency when meet TiDB "amend + add column default xxx" Data Inconsistency when meet TiDB "amend + add column datetime default 'xxx'" Dec 16, 2021
@maxshuang maxshuang changed the title Data Inconsistency when meet TiDB "amend + add column datetime default 'xxx'" Data Inconsistency when meet TiDB "amend + add column default 'xxx'" Dec 17, 2021
overvenus pushed a commit that referenced this issue Dec 31, 2021
#3930)

* fix(mounter(ticdc)): fix mounter default value panic and data inconsistence

close  #3929 #3918
@VelocityLight
Copy link

update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 affects-5.0 affects-5.1 affects-5.2 affects-5.3 area/ticdc Issues or PRs related to TiCDC. severity/major subject/correctness Denotes an issue or pull request is related to correctness. type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants