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

sys var: add tidb_enable_shared_lock_upgrade #18447

Merged
merged 13 commits into from
Aug 15, 2024
4 changes: 3 additions & 1 deletion pessimistic-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ Pessimistic transactions in TiDB behave similarly to those in MySQL. See the min

2. TiDB does not support `SELECT LOCK IN SHARE MODE`.

When `SELECT LOCK IN SHARE MODE` is executed, it has the same effect as that without the lock, so the read or write operation of other transactions is not blocked.
TiDB does not support `SELECT LOCK IN SHARE MODE` by default.

Starting from v8.3.0, TiDB supports using the [`tidb_enable_shared_lock_upgrade`](/system-variables.md#tidb_enable_shared_lock_upgrade-new-in-v8.3.0) system variable to enable the `SELECT LOCK IN SHARE MODE` statement. After enabling, the `SELECT LOCK IN SHARE MODE` statement will be upgraded to the `SELECT FOR UPDATE` statement, which adds pessimistic locks to the data rows.
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

3. DDL may result in failure of the pessimistic transaction commit.

Expand Down
10 changes: 10 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,16 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;
- Value options: `OFF`, `ON`
- This variable controls whether TiDB enables chunk objects cache. If the value is `ON`, TiDB prefers to use the cached chunk object and only requests from the system if the requested object is not in the cache. If the value is `OFF`, TiDB requests chunk objects from the system directly.

### tidb_enable_shared_lock_upgrade <span class="version-mark">New in v8.3.0</span>
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

- Scope: SESSION | GLOBAL
- Persists to cluster: Yes
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
- Type: Boolean
- Default value: `OFF`
- This variable controls whether to enable the function of upgrading shared locks to exclusive locks. TiDB does not support `SELECT LOCK IN SHARE MODE` by default. When the variable value is `ON`, TiDB will try to upgrade the `SELECT LOCK IN SHARE MODE` statement to `SELECT FOR UPDATE` and add a pessimistic lock. The default value of this variable is `OFF`, which means that the function of upgrading shared locks to exclusive locks is disabled.
- If this variable and [`tidb_enable_noop_functions`](#tidb_enable_noop_functions-new-in-v40) are enabled at the same time, this variable will take effect for the the `SELECT LOCK IN SHARE MODE` statement.
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

### tidb_enable_slow_log

> **Note:**
Expand Down
Loading