Skip to content

Commit 6d6f75b

Browse files
authored
DOCSP-35201 Backport Transaction Retry Logic in Core API (#1164) (#1166)
1 parent fca884b commit 6d6f75b

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

source/crud/transactions.txt

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,43 @@ the ``startTransaction()`` method:
304304
Transaction Errors
305305
------------------
306306

307-
If you are using the Core API to perform a transaction, you must incorporate
308-
error-handling logic into your application for the following errors:
309-
310-
- ``TransientTransactionError``: Raised if a write operation errors
311-
before the driver commits the transaction. To learn more about this error, see the
312-
:manual:`TransientTransactionError description
313-
</core/transactions-in-applications/#transienttransactionerror>` on
314-
the Driver API page in the Server manual.
315-
- ``UnknownTransactionCommitResult``: Raised if the commit operation
316-
encounters an error. To learn more about this error, see the
317-
:manual:`UnknownTransactionCommitResult description
318-
</core/transactions-in-applications/#unknowntransactioncommitresult>` on
319-
the Driver API page in the Server manual.
320-
321-
The Convenient Transaction API incorporates retry logic for these error
322-
types, so the driver retries the transaction until there is a successful commit.
307+
Because MongoDB transactions are :website:`ACID compliant
308+
</basics/acid-transactions>`, the driver might produce errors during operation
309+
to ensure your data maintains consistent. If the following errors occur, your
310+
application must retry the transaction:
311+
312+
- ``TransientTransactionError``: Raised if a write operation encounters an error
313+
before the driver commits the transaction. To learn more about this error
314+
type, see the :manual:`TransientTransactionError
315+
description </core/transactions-in-applications/#transienttransactionerror>` on
316+
the Drivers API page in the Server manual.
317+
- ``UnknownTransactionCommitResult``: Raised if the commit operation encounters
318+
an error. To learn more about this error type, see the
319+
:manual:`UnknownTransactionCommitResult
320+
description </core/transactions-in-applications/#unknowntransactioncommitresult>`
321+
on the Drivers API page in the Server manual.
322+
323+
The following sections describe how to handle these errors when using different APIs.
324+
325+
Convenient Transaction API Error Handling
326+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327+
328+
The Convenient Transaction API incorporates retry logic for these error types.
329+
The driver automatically retries the transaction until there is a successful
330+
commit.
331+
332+
Core API Error Handling
333+
~~~~~~~~~~~~~~~~~~~~~~~
334+
335+
If you are using the Core API to perform a transaction, you must add the following
336+
error-handling functions to your application:
337+
338+
- A function that retries the entire transaction when the driver encounters a
339+
``TransientTransactionError``
340+
- A function that retries the commit operation when the driver encounters an
341+
``UnknownTransactionCommitResult``
342+
343+
These functions must run until there is a successful commit or a different
344+
error. For an example of this retry logic, see the :manual:`Core API section
345+
</core/transactions-in-applications/#core-api>` on the Drivers API page in the
346+
Server manual.

0 commit comments

Comments
 (0)