From c2d9aaaa7051483012d5881c1d856f8381393332 Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:19:51 +0800 Subject: [PATCH] Add declaration for scopes of transaction related variables and configurations (#5056) (#5057) --- tidb-specific-system-variables.md | 8 +++++--- transaction-overview.md | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tidb-specific-system-variables.md b/tidb-specific-system-variables.md index cf0b034a4c2f1..8d06b7f2898cf 100644 --- a/tidb-specific-system-variables.md +++ b/tidb-specific-system-variables.md @@ -34,7 +34,7 @@ set @@global.tidb_distsql_scan_concurrency = 10 - Default value: 0 - This variable indicates whether to import data from the dump file currently. - To speed up importing, the unique index constraint is not checked when the variable is set to 1. -- This variable is only used by Lightning. Do not modify it. +- This variable is only used by TiDB Lightning. Do not modify it. ### tidb_opt_agg_push_down @@ -201,13 +201,13 @@ set @@global.tidb_distsql_scan_concurrency = 10 - 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 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 is applicable only to optimistic transactions, not to pessimistic transactions. ### tidb_disable_txn_auto_retry - Scope: SESSION | GLOBAL - Default: 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. @@ -215,6 +215,8 @@ set @@global.tidb_distsql_scan_concurrency = 10 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_backoff_weight - Scope: SESSION | GLOBAL diff --git a/transaction-overview.md b/transaction-overview.md index 2ddc7274ab13a..0959e5a3b1c8d 100644 --- a/transaction-overview.md +++ b/transaction-overview.md @@ -10,6 +10,10 @@ TiDB supports complete distributed transactions. Both [optimistic transaction mo The common variables include [`autocommit`](#autocommit), [`tidb_disable_txn_auto_retry`](/tidb-specific-system-variables.md#tidb_disable_txn_auto_retry), and [`tidb_retry_limit`](/tidb-specific-system-variables.md#tidb_retry_limit). +> **Note:** +> +> The [`tidb_disable_txn_auto_retry`](/tidb-specific-system-variables.md#tidb_disable_txn_auto_retry) and [`tidb_retry_limit`](/tidb-specific-system-variables.md#tidb_retry_limit) variables only apply to optimistic transactions, not to pessimistic transactions. + ## Common syntax ### `BEGIN`, `START TRANSACTION` and `START TRANSACTION WITH CONSISTENT SNAPSHOT`