-
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
Point get may acquire unnecessary locks #21688
Comments
Tested in MySQL-5.7 and MySQL-8.0, point get and scan will both be locked by a wired X lock. |
@you06 Yes, however, it won't be locked if we enable /* init */ select version();
-- init >> +-----------+
-- init | VERSION() |
-- init +-----------+
-- init | 5.7.31 |
-- init +-----------+
/* init */ drop table if exists t;
-- init >> 0 rows affected
/* init */ create table t (k1 int, k2 int, v int, unique key (k1));
-- init >> 0 rows affected
/* init */ insert into t values (1, 1, null), (2, 2, 2);
-- init >> 2 rows affected
/* t0 */ begin;
-- t0 >> 0 rows affected
/* t1 */ begin;
-- t1 >> 0 rows affected
/* t0 */ update t set v = 10 where (k2, v) in ((1, null)); -- 0 row affected (table scan)
-- t0 >> 0 rows affected
/* t1 */ update t set v = 11 where (k2, v) in ((1, null)); -- won't be blocked
-- t1 >> blocked
/* t0 */ commit;
-- t0 >> 0 rows affected
-- t1 >> resumed
-- t1 >> 0 rows affected
/* t1 */ commit;
-- t1 >> 0 rows affected |
This issue exists in release-4.0 only.
I'll find out where the difference comes. |
However, #21061 does not solve this problem completely, if there is a condition which is possible matching row, it'll also lock the row unexpectedly. The following case still blocked in master.
|
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Note that the
update
of t1 won't be blocked if we use table scan as following.2. What did you expect to see? (Required)
Since nothing has been updated by t0, t1 shouldn't be blocked by it.
3. What did you see instead (Required)
t1 was blocked by t0 when using point get.
4. What is your TiDB version? (Required)
release-4.0 (2862cd7)
The text was updated successfully, but these errors were encountered: