Skip to content

Union all with point get for update and table scan for update returns wrong result #32045

@lcwangchao

Description

@lcwangchao

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

prepare data

mysql> create table t1(id int primary key, v int);
mysql> insert into t1 values(1, 100);
mysql> begin pessimistic; -- session1
             mysql> update t1 set v=v+1 where id=1; -- session2
mysql> select * from t1 where id =1 for update union all select * from t1 for update; --> session1

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

+----+-----+
| id | v   |
+----+-----+
| 1  | 101 |
| 1  | 101 |
+----+-----+

3. What did you see instead (Required)

+----+-----+
| id | v   |
+----+-----+
| 1  | 100 |
| 1  | 101 |
+----+-----+

4. What is your TiDB version? (Required)

mater

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.5.0-alpha
Edition: Community
Git Commit Hash: 05a4c65937a3d1a7ccd43b4779f4b8c546b7cb43
Git Branch: heads/refs/tags/v5.5.0-alpha
UTC Build Time: 2022-01-21 07:47:23
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-5.0This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.affects-6.0affects-6.1This bug affects the 6.1.x(LTS) versions.may-affects-4.0This bug maybe affects 4.0.x versions.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions