Skip to content

Commit

Permalink
Add declaration for scopes of transaction related variables and confi…
Browse files Browse the repository at this point in the history
…gurations
  • Loading branch information
Joyinqin committed Mar 18, 2021
1 parent ca331fb commit cf43a29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,16 @@ Constraint checking is always performed in place for pessimistic transactions (d

- Scope: SESSION | GLOBAL
- Default value: ON
- This variable is used to set whether to disable the automatic retry of explicit transactions. The default value of `ON` means that transactions will not automatically retry in TiDB and `COMMIT` statements might return errors that need to be handled in the application layer.
- This variable is used to set whether to disable the automatic retry of explicit optimistic transactions. The default value of `ON` means that transactions will not automatically retry in TiDB and `COMMIT` statements might return errors that need to be handled in the application layer.

Setting the value to `OFF` means that TiDB will automatically retry transactions, resulting in fewer errors from `COMMIT` statements. Be careful when making this change, because it might result in lost updates.

This variable does not affect automatically committed implicit transactions and internally executed transactions in TiDB. The maximum retry count of these transactions is determined by the value of `tidb_retry_limit`.

For more details, see [limits of retry](/optimistic-transaction.md#limits-of-retry).

This variable only applies to optimistic transactions, not to pessimistic transactions. The number of retries for pessimistic transactions is controlled by [`max_retry_count`](/tidb-configuration-file.md#max-retry-count).

### tidb_distsql_scan_concurrency

- Scope: SESSION | GLOBAL
Expand Down Expand Up @@ -952,7 +954,7 @@ SET tidb_query_log_max_len = 20

- Scope: SESSION | GLOBAL
- Default value: 10
- This variable is used to set the maximum number of the retries. When a transaction encounters retryable errors (such as transaction conflicts, very slow transaction commit, or table schema changes), this transaction is re-executed according to this variable. Note that setting `tidb_retry_limit` to `0` disables the automatic retry.
- This variable is used to set the maximum number of the retries for optimistic transactions. When a transaction encounters retryable errors (such as transaction conflicts, very slow transaction commit, or table schema changes), this transaction is re-executed according to this variable. Note that setting `tidb_retry_limit` to `0` disables the automatic retry. This variable only applies to optimistic transactions, not to pessimistic transactions.

### tidb_row_format_version

Expand Down
4 changes: 4 additions & 0 deletions transaction-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ This document introduces commonly used transaction-related statements, explicit

The common variables include [`autocommit`](#autocommit), [`tidb_disable_txn_auto_retry`](/system-variables.md#tidb_disable_txn_auto_retry), [`tidb_retry_limit`](/system-variables.md#tidb_retry_limit), and [`tidb_txn_mode`](/system-variables.md#tidb_txn_mode).

> **Note:**
>
> The [`tidb_disable_txn_auto_retry`](/system-variables.md#tidb_disable_txn_auto_retry) and [`tidb_retry_limit`](/system-variables.md#tidb_retry_limit) variables only apply to optimistic transactions, not to pessimistic transactions.
## Common statements

### Starting a transaction
Expand Down

0 comments on commit cf43a29

Please sign in to comment.