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

TiDB (with tikv) produces different results for SELECT statements when using transaction #38125

Closed
JZuming opened this issue Sep 23, 2022 · 1 comment
Labels
duplicate Issues or pull requests already exists. may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@JZuming
Copy link

JZuming commented Sep 23, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Setup the environment:

tiup playground --db.binpath /path/to/latest/tidb-server &

Testcase 1

mysql -h "127.0.0.1" -u root -P 4000 -D testdb < mysql_bk.sql
mysql -h "127.0.0.1" -u root -P 4000 -D testdb

mysql> update t_8uiwcc set wkey = 264;
mysql> select * from
  t_rxo2lc
where (case when 55
           > case when t_rxo2lc.c_4j_5y not in (
            select
                  ref_0.c_do8jqc as c0
                from
                  t_8uiwcc as ref_0
                where 24 >= 100
              union
              select
                  ref_1.pkey as c0
                from
                  t_8uiwcc as ref_1
                where 49 <= 75) then 14 else 63 end
           then 1 else 78 end
       between 6 and 100);

Testcase 2

mysql -h "127.0.0.1" -u root -P 4000 -D testdb < mysql_bk.sql
mysql -h "127.0.0.1" -u root -P 4000 -D testdb

mysql> start transaction;
mysql> update t_8uiwcc set wkey = 264;
mysql> select * from
  t_rxo2lc
where (case when 55
           > case when t_rxo2lc.c_4j_5y not in (
            select
                  ref_0.c_do8jqc as c0
                from
                  t_8uiwcc as ref_0
                where 24 >= 100
              union
              select
                  ref_1.pkey as c0
                from
                  t_8uiwcc as ref_1
                where 49 <= 75) then 14 else 63 end
           then 1 else 78 end
       between 6 and 100);
mysql> commit;

mysql_bk.sql: mysql_bk.txt

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

The execution result of SELECT statements in Testcase 1 and Testcase 2 are same.

3. What did you see instead (Required)

Output of SELECT statement in Testcase 1

+------+---------+----------+----------+----------+----------+---------+--------------------+----------+----------+----------+----------+
| wkey | pkey    | c_tqng_c | c_0x5nid | c_dwgced | c_wngutc | c_4j_5y | c_rh_b1d           | c_2kjcpc | c_5nxshb | c_nntyvd | c__v1pmd |
+------+---------+----------+----------+----------+----------+---------+--------------------+----------+----------+----------+----------+
|  450 | 1057000 | NULL     |  1057000 | o83s     | o0jzo    |    NULL | 1703.8446113454934 |    60.85 | o83s     | o83s     | NULL     |
|  450 | 1058000 | v5gptc   |  1058000 | NULL     | qvpggb   |    NULL | 1703.8446113454934 |    71.91 | NULL     | NULL     | v5gptc   |
|  450 | 1059000 | mtjffd   |  1059000 | ojmxkc   | NULL     |    NULL | 1703.8446113454934 |    100.5 | ojmxkc   | ojmxkc   | mtjffd   |
+------+---------+----------+----------+----------+----------+---------+--------------------+----------+----------+----------+----------+

Output of SELECT statement in Testcase 2

Empty set (0.00 sec)

Their results are different.

4. What is your TiDB version? (Required)

Release Version: v6.2.0
Edition: Community
Git Commit Hash: daf2b17cdfe30c02ce282361009fb5bdb05f2b0e
Git Branch: HEAD
UTC Build Time: 2022-09-22 19:59:46
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
@JZuming JZuming added the type/bug The issue is confirmed as a bug. label Sep 23, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Sep 23, 2022
@aytrack aytrack 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. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Sep 23, 2022
@aytrack aytrack added affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 labels Sep 23, 2022
@you06
Copy link
Contributor

you06 commented Sep 23, 2022

Hi, thanks for the issue. I made a bisect and this issue is fixed by #36961, the root cause is same with #36903.

@you06 you06 closed this as completed Sep 23, 2022
@cfzjywxk cfzjywxk added duplicate Issues or pull requests already exists. severity/major and removed severity/critical 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. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 labels Sep 26, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues or pull requests already exists. may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants