diff --git a/system-variables.md b/system-variables.md index 7f2947702a577..dc0e6afea44f2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -246,7 +246,7 @@ Constraint checking is always performed in place for pessimistic transactions (d - 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. @@ -254,6 +254,8 @@ Constraint checking is always performed in place for pessimistic transactions (d 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_enable_amend_pessimistic_txn` New in v4.0.7 - Scope: SESSION | GLOBAL @@ -695,7 +697,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. 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 diff --git a/transaction-overview.md b/transaction-overview.md index 4caeac2532711..e9500030d4ddc 100644 --- a/transaction-overview.md +++ b/transaction-overview.md @@ -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