-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Update with sub query uses incorrect snapshot in RR isolation level #45677
Comments
We analyze the cause of this bug by explaining the execution plan: MySQL [test]> explain update t set b=3 where b = (select b from t as t2 where b=2);
+--------------------+---------+------+---------------+---------------+
| id | estRows | task | access object | operator info |
+--------------------+---------+------+---------------+---------------+
| Update_15 | N/A | root | | N/A |
| └─TableDual_17 | 0.00 | root | | rows:0 |
+--------------------+---------+------+---------------+---------------+
2 rows in set (0.01 sec) The sub query in update is executed as a single query and uses snapshot read. Since the execution of |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
init database with 1 row as below.
Then start two session and update that row in session2 after session1 starts a transaction.
Then execute a update with sub query in session1.
2. What did you expect to see? (Required)
The last select returns:
3. What did you see instead (Required)
The last select returns:
We also check the behaviour of normal update in the case below.
Then it returns:
as expected.
Note that
update t set b=3 where b=2;
andupdate t set b=3 where b=(select b from t where b=2);
have the same meaning in these two cases. It;s confusing to have different results.4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: