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

Incorrect select result after point update nothing #28011

Closed
zyguan opened this issue Sep 13, 2021 · 3 comments · Fixed by #42488
Closed

Incorrect select result after point update nothing #28011

zyguan opened this issue Sep 13, 2021 · 3 comments · Fixed by #42488
Assignees
Labels
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. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 duplicate Issues or pull requests already exists. severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@zyguan
Copy link
Contributor

zyguan commented Sep 13, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

TiKV is required, then execute the following SQL.

/* test */ drop table if exists t1;
/* test */ create table t1(c_int int, c_str varchar(40), unique key uk(c_int));
/* test */ insert into t1 (`c_int`, `c_str`) values (6, 'relaxed chatelet');
/* test */ begin;
/* test */ update t1 set c_int = c_int + 5, c_str = 'dreamy taussig' where (c_int, c_str) in ((6, 'frosty hopper'), (6, 'funny sutherland'));
/* test */ select c_int from t1;
/* test */ select c_int, c_str from t1;
/* test */ commit;

This issue is introduced by #25730 and seems to be fixed by #26759 by accident (after which IndexLookUp gets used).

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

/* test */ select c_int from t1;
-- test >> +-------+
-- test    | C INT |
-- test    +-------+
-- test    |     6 |
-- test    +-------+
/* test */ select c_int, c_str from t1;
-- test >> +-------+------------------+
-- test    | C INT |      C STR       |
-- test    +-------+------------------+
-- test    |     6 | relaxed chatelet |
-- test    +-------+------------------+

3. What did you see instead (Required)

/* test */ select c_int from t1;
-- test >> +-------+
-- test    | C INT |
-- test    +-------+
-- test    |     6 |
-- test    |     6 |
-- test    +-------+
/* test */ select c_int, c_str from t1;
-- test >> +-------+------------------+
-- test    | C INT |      C STR       |
-- test    +-------+------------------+
-- test    |     6 | relaxed chatelet |
-- test    +-------+------------------+

4. What is your TiDB version? (Required)

release-5.0
release-5.1

@zyguan zyguan added type/bug The issue is confirmed as a bug. sig/transaction SIG:Transaction labels Sep 13, 2021
@cfzjywxk
Copy link
Contributor

The cause is similar with #28011, currently the merge operation done by the union scan operater will consider the handle key but not the unique key. As a result there will be some weird in transaction query results such as returning same index values for a unique index, like the examples described in #28011.

The data consistency will not be affected, but It will be confusing if the user query data for some updates in transaction.

@ChenPeng2013 ChenPeng2013 added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. severity/critical labels Sep 14, 2021
@cfzjywxk
Copy link
Contributor

@zyguan
As the root cause of this issue is related to the describtions in #28011, but the change in #25730 increases the rate encountered by the client, I think we could change the severity to major.

@vivid392845427
Copy link

vivid392845427 commented Dec 31, 2021

duplicate with 24159 and 30823 , master branch does not appear,due to the execution plan of the update in transaction did not use point_get, but use IndexLookUp,appears when union scan + point_get + select use unqiue index

@vivid392845427 vivid392845427 added duplicate Issues or pull requests already exists. and removed severity/major labels Dec 31, 2021
@jebter jebter added affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 labels Mar 16, 2023
@zyguan zyguan assigned zyguan and unassigned cfzjywxk Mar 16, 2023
zyguan added a commit to zyguan/tidb that referenced this issue Mar 22, 2023
@ti-chi-bot ti-chi-bot added the may-affects-4.0 This bug maybe affects 4.0.x versions. label Mar 22, 2023
@zyguan zyguan removed the may-affects-4.0 This bug maybe affects 4.0.x versions. label Mar 22, 2023
ti-chi-bot pushed a commit that referenced this issue Mar 23, 2023
@VelocityLight VelocityLight added affects-5.4 This bug affects 5.4.x versions. and removed affects-5.4 This bug affects 5.4.x versions. labels Mar 23, 2023
zyguan added a commit to zyguan/tidb that referenced this issue Mar 25, 2023
This reverts commit 3a5f434.

Signed-off-by: zyguan <[email protected]>
ti-chi-bot pushed a commit that referenced this issue Mar 26, 2023
zyguan added a commit to ti-chi-bot/tidb that referenced this issue Mar 29, 2023
ti-chi-bot added a commit that referenced this issue Apr 3, 2023
you06 added a commit to you06/tidb that referenced this issue May 19, 2023
you06 added a commit to you06/tidb that referenced this issue May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 duplicate Issues or pull requests already exists. severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants