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

SELECT LOCK IN SHARE MODE is unsafe #19383

Closed
ghost opened this issue Aug 24, 2020 · 4 comments · Fixed by #19506
Closed

SELECT LOCK IN SHARE MODE is unsafe #19383

ghost opened this issue Aug 24, 2020 · 4 comments · Fixed by #19506
Labels
component/expression severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@ghost
Copy link

ghost commented Aug 24, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

See: https://docs.pingcap.com/tidb/stable/pessimistic-transaction#difference-with-mysql-innodb

Under (2) it says that SELECT LOCK IN SHARE MODE is a noop. This seems unsafe, at least by default.

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

I would like to see it protected by the feature tidb_enable_noop_functions. This will allow users to explicitly turn it on, if they require syntax support but are fine with a noop.

3. What did you see instead (Required)

The statement executes without errors.

4. What is your TiDB version? (Required)

All versions.

@ghost ghost added the type/bug The issue is confirmed as a bug. label Aug 24, 2020
@time-and-fate
Copy link
Member

/label sig/transaction

@ti-srebot ti-srebot added the sig/transaction SIG:Transaction label Aug 24, 2020
@ghost ghost self-assigned this Aug 26, 2020
@ghost
Copy link
Author

ghost commented Aug 26, 2020

This seems similar to #19506 -- I will take a look after it merges.

@sre-bot
Copy link
Contributor

sre-bot commented Sep 21, 2020

Integrity check:
RCA symptom trigger_condition wa affect_version fix_version fields are empty
@nullnotnil
Please comment /info to get template

@ti-srebot
Copy link
Contributor

ti-srebot commented Sep 21, 2020

Please edit this comment to complete the following information

Bug

1. Root Cause Analysis (RCA)

The syntax SELECT.. LOCK IN SHARE MODE was added to the TiDB parser, but no errors or warnings were added to TiDB when using this syntax. This could lead to a user believing that a shared lock was taken, but no such lock exists in TiDB. In the absence of this feature existing in TiDB, it is important to provide an error to the user so they do not use a shared lock to prevent against modifications.

2. Symptom

When using the syntax SELECT .. LOCK IN SHARE MODE.

3. All Trigger Conditions

see in Minimal reproduce step

4. Workaround (optional)

The user can SELECT .. FOR UPDATE which is supported by TiDB, or as part of the fix for this issue SET tidb_enable_noop_functions = 1.

5. Affected versions

[v4.0.0:v4.0.99]

6. Fixed versions

unplaned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression severity/major 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.

5 participants