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

Retrying transaction with a double type auto-increment column leads to data error #29892

Closed
djshow832 opened this issue Nov 18, 2021 · 4 comments · Fixed by #29997
Closed

Retrying transaction with a double type auto-increment column leads to data error #29892

djshow832 opened this issue Nov 18, 2021 · 4 comments · Fixed by #29997
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@djshow832
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Prepare:

tidb> set global tidb_txn_mode='optimistic';
Query OK, 0 rows affected (0.01 sec)

tidb> set global tidb_disable_txn_auto_retry=false;
Query OK, 0 rows affected (0.01 sec)

In session1:

session1> create table t(a double key auto_increment, b int);
Query OK, 0 rows affected (0.03 sec)
session1> insert into t values (146576794, 1);
Query OK, 1 row affected (0.01 sec)
session1> begin;
session1> insert into t(b) select 1;

In session2:

session2> begin;
Query OK, 0 rows affected (0.00 sec)
session2> insert into t values (146576795, 1);
Query OK, 1 row affected (0.00 sec)
session2> insert into t values (146576796, 1);                             
Query OK, 1 row affected (0.00 sec)
session2> commit;
Query OK, 0 rows affected (0.01 sec)

In session1:

session1> commit;
Query OK, 0 rows affected (2.63 sec)
session1> select * from t;
ERROR 1105 (HY000): Failed to decode datum payload as f64

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

Query without an error.

3. What did you see instead (Required)

ERROR 1105 (HY000): Failed to decode datum payload as f64

4. What is your TiDB version? (Required)

master

@djshow832 djshow832 added type/bug The issue is confirmed as a bug. severity/critical labels Nov 18, 2021
@jebter jebter added the sig/transaction SIG:Transaction label Nov 18, 2021
@djshow832
Copy link
Contributor Author

The reason is we called SetAutoID instead of setDatumAutoIDAndCast.

if retryInfo.Retrying {
id, ok := retryInfo.GetCurrAutoIncrementID()
if ok {
d.SetAutoID(id, c.Flag)
return d, nil

@dveeden
Copy link
Contributor

dveeden commented Nov 19, 2021

Could #29369 be related?

@AilinKid
Copy link
Contributor

/assign

@djshow832 djshow832 added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Nov 22, 2021
@cfzjywxk cfzjywxk removed their assignment Nov 22, 2021
@cfzjywxk cfzjywxk added sig/sql-infra SIG: SQL Infra and removed sig/transaction SIG:Transaction labels Nov 22, 2021
@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants