From 6874ee58f32b28373514f73ce26883a527dfc974 Mon Sep 17 00:00:00 2001 From: houfaxin Date: Thu, 16 Oct 2025 21:52:08 +0800 Subject: [PATCH 1/5] Update optimistic-transaction.md --- optimistic-transaction.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/optimistic-transaction.md b/optimistic-transaction.md index c9f7192711ea0..bc7b8198b3817 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -72,6 +72,10 @@ In the optimistic transaction model, transactions might fail to be committed bec ### Automatic retry +> **Note:** +> +> Starting from TiDB v3.0, the automatic retry of transactions is disabled by default. It is not recommended to enable the automatic retry because it might **break the transaction isolation level**. + If a write-write conflict occurs during the transaction commit, TiDB automatically retries the SQL statement that includes write operations. You can enable the automatic retry by setting `tidb_disable_txn_auto_retry` to `OFF` and set the retry limit by configuring `tidb_retry_limit`: ```toml From 532cdf28139b108d422a425b9e38a8a97e52351c Mon Sep 17 00:00:00 2001 From: houfaxin Date: Thu, 16 Oct 2025 21:52:37 +0800 Subject: [PATCH 2/5] Update optimistic-transaction.md --- optimistic-transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimistic-transaction.md b/optimistic-transaction.md index bc7b8198b3817..5930bba2de52c 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -68,7 +68,7 @@ However, TiDB transactions also have the following disadvantages: > > Starting from v8.0.0, the [`tidb_disable_txn_auto_retry`](/system-variables.md#tidb_disable_txn_auto_retry) system variable is deprecated, and TiDB no longer supports automatic retries of optimistic transactions. It is recommended to use the [Pessimistic transaction mode](/pessimistic-transaction.md). If you encounter optimistic transaction conflicts, you can capture the error and retry transactions in your application. -In the optimistic transaction model, transactions might fail to be committed because of write–write conflict in heavy contention scenarios. Starting from v3.0.8, TiDB uses the [pessimistic transaction mode](/pessimistic-transaction.md) by default, the same as MySQL. This means that TiDB and MySQL add locks during the execution of write-type SQL statements, and its Repeatable Read isolation level allows for current reads, so commits generally do not encounter exceptions. To lower the difficulty of adapting applications, TiDB provides an internal retry mechanism. +In the optimistic transaction model, transactions might fail to be committed because of write–write conflict in heavy contention scenarios. Starting from v3.0.8, TiDB uses the [pessimistic transaction mode](/pessimistic-transaction.md) by default, the same as MySQL. This means that TiDB and MySQL add locks during the execution of write-type SQL statements, and its Repeatable Read isolation level allows for current reads, so commits generally do not encounter exceptions. ### Automatic retry From fdcb91d2136df14674568c9659b90caf0c73a811 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 16 Oct 2025 22:00:44 +0800 Subject: [PATCH 3/5] Update optimistic-transaction.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- optimistic-transaction.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/optimistic-transaction.md b/optimistic-transaction.md index 5930bba2de52c..81a57214ee882 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -74,7 +74,8 @@ In the optimistic transaction model, transactions might fail to be committed bec > **Note:** > -> Starting from TiDB v3.0, the automatic retry of transactions is disabled by default. It is not recommended to enable the automatic retry because it might **break the transaction isolation level**. +> - Starting from TiDB v3.0, the automatic retry of transactions is disabled by default, because it can **break the transaction isolation level**. +> - Starting from TiDB v8.0.0, this feature is deprecated and no longer supported. If a write-write conflict occurs during the transaction commit, TiDB automatically retries the SQL statement that includes write operations. You can enable the automatic retry by setting `tidb_disable_txn_auto_retry` to `OFF` and set the retry limit by configuring `tidb_retry_limit`: From 1d915053e7e541d63e245f6e65af85c74e114dc8 Mon Sep 17 00:00:00 2001 From: houfaxin Date: Thu, 16 Oct 2025 22:03:07 +0800 Subject: [PATCH 4/5] Update optimistic-transaction.md --- optimistic-transaction.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/optimistic-transaction.md b/optimistic-transaction.md index 81a57214ee882..7d606f740539e 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -74,8 +74,8 @@ In the optimistic transaction model, transactions might fail to be committed bec > **Note:** > -> - Starting from TiDB v3.0, the automatic retry of transactions is disabled by default, because it can **break the transaction isolation level**. -> - Starting from TiDB v8.0.0, this feature is deprecated and no longer supported. +> - Starting from TiDB v3.0.0, the automatic retry of transactions is disabled by default, because it can **break the transaction isolation level**. +> - Starting from TiDB v8.0.0, automatic retry is deprecated and no longer supported. If a write-write conflict occurs during the transaction commit, TiDB automatically retries the SQL statement that includes write operations. You can enable the automatic retry by setting `tidb_disable_txn_auto_retry` to `OFF` and set the retry limit by configuring `tidb_retry_limit`: From 1cf4d823938d53e6ce2d2d7df5d57c6faef1af93 Mon Sep 17 00:00:00 2001 From: houfaxin Date: Thu, 16 Oct 2025 22:04:05 +0800 Subject: [PATCH 5/5] Update optimistic-transaction.md --- optimistic-transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimistic-transaction.md b/optimistic-transaction.md index 7d606f740539e..8c3335b46be2c 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -75,7 +75,7 @@ In the optimistic transaction model, transactions might fail to be committed bec > **Note:** > > - Starting from TiDB v3.0.0, the automatic retry of transactions is disabled by default, because it can **break the transaction isolation level**. -> - Starting from TiDB v8.0.0, automatic retry is deprecated and no longer supported. +> - Starting from TiDB v8.0.0, automatic retries of optimistic transactions are no longer supported. If a write-write conflict occurs during the transaction commit, TiDB automatically retries the SQL statement that includes write operations. You can enable the automatic retry by setting `tidb_disable_txn_auto_retry` to `OFF` and set the retry limit by configuring `tidb_retry_limit`: