From fd852ab8f170c23e93ac8e600ca80ca51c14f27b 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 78f3efd1de1f3..2e30e5dc6fa9d 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -73,6 +73,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 09ede060e6b6764eed1f2cd0f110e9329b723ce9 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 2e30e5dc6fa9d..97e0bc114c4e4 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -69,7 +69,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 8f76cef738352e1466e210af84194aa9ba85dbfe 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 97e0bc114c4e4..791d4daab2347 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -75,7 +75,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 300e0cc85b5ddc91ca1f1ea72f025cb6b17e8cec 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 791d4daab2347..542a039ca96b0 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -75,8 +75,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 580804da1beffdd86805133abac8a0afd6619478 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 542a039ca96b0..215c1df82d82c 100644 --- a/optimistic-transaction.md +++ b/optimistic-transaction.md @@ -76,7 +76,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`: