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

txn: unexpected behavior for point-get and LOCK IN SHARE MODE #52432

Closed
bb7133 opened this issue Apr 9, 2024 · 2 comments · Fixed by #53279
Closed

txn: unexpected behavior for point-get and LOCK IN SHARE MODE #52432

bb7133 opened this issue Apr 9, 2024 · 2 comments · Fixed by #53279
Assignees
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-7.6 affects-8.0 affects-8.1 This bug affects the 8.1.x(LTS) versions. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. severity/moderate sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@bb7133
Copy link
Member

bb7133 commented Apr 9, 2024

Bug Report

1. Minimal reproduce step (Required)

Using LOCK IN SHARED MODE in a point-get query:

set @@tidb_enable_noop_functions='OFF';
create table t(a int key, b int);
insert into t values (1, 1), (2, 2);
select * from t where a=1 lock in share mode;
select * from t where b=1 lock in share mode;

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

According to TiDB document, TiDB should report an error using SHARE IN LOCK MODE when tidb_enable_noop_functions=OFF.

3. What did you see instead (Required)

tidb> select * from t where a=1 lock in share mode;
+---+------+
| a | b    |
+---+------+
| 1 |    1 |
+---+------+
1 row in set (5.80 sec)

tidb> select * from t where b=1 lock in share mode;
ERROR 1235 (42000): function LOCK IN SHARE MODE has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions

4. What is your TiDB version? (Required)

All versions of TiDB have this issue, I believe.

5. Root cause analysis

Notice that for select * from t where a=1 lock in share mode, TiDB uses a 'fast path' for point-get, we didn't handle LOCK IN SHARE MODE in this path.

@bb7133 bb7133 added type/bug The issue is confirmed as a bug. sig/transaction SIG:Transaction labels Apr 9, 2024
@cfzjywxk cfzjywxk added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. severity/moderate affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-7.6 affects-8.0 affects-8.1 This bug affects the 8.1.x(LTS) versions. labels Apr 15, 2024
@henrybw
Copy link
Contributor

henrybw commented May 7, 2024

/assign

@bb7133
Copy link
Member Author

bb7133 commented May 7, 2024

Hi @henrybw, thanks for picking this issue!

Notice that for select * from t where a=1 lock in share mode, TiDB uses a 'fast path' for point-get, we didn't handle LOCK IN SHARE MODE in this path.

For some further info useful for your commit:

For 'non fast path', you could find the checking for LockMode in: logical_plan_builder.go#L4189-L4210

Then for 'fast path', the checking for 'lock clause' is in point_get_plan.go#L867-L903, and I believe that we should update codes here to achieve similar logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-7.6 affects-8.0 affects-8.1 This bug affects the 8.1.x(LTS) versions. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. severity/moderate 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.

3 participants