From f92a0166f1ba5734e1abbde9d77f23340ec7e116 Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Wed, 18 Jun 2025 12:01:00 -0400 Subject: [PATCH] DOCSP-35201 Transaction Retry Logic in Core API (#1164) * DOCSP-35201 add section linking to solutions for transaction retry logic in node Core API * DOCSP-35201 adding more details for retry logic * DOCSP-35201 edit for clarity, add list of functions * DOCSP-35201 restructuring for clarity and brevity * DOCSP-35201 fixing links * DOCSP-35201 remove double error in title * DOCSP-35201 fix sentences * DOCSP-35201 style guide changes/wording * DOCSP-35201 add API to title * Update source/crud/transactions.txt Co-authored-by: Mike Woofter <108414937+mongoKart@users.noreply.github.com> * DOCSP-35201 grammar changes --------- Co-authored-by: Mike Woofter <108414937+mongoKart@users.noreply.github.com> (cherry picked from commit 53d8927d12be061dbb41276622f525b328238b75) --- source/crud/transactions.txt | 56 +++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/source/crud/transactions.txt b/source/crud/transactions.txt index 4a82050d4..5a18b9c0e 100644 --- a/source/crud/transactions.txt +++ b/source/crud/transactions.txt @@ -304,19 +304,43 @@ the ``startTransaction()`` method: Transaction Errors ------------------ -If you are using the Core API to perform a transaction, you must incorporate -error-handling logic into your application for the following errors: - -- ``TransientTransactionError``: Raised if a write operation errors - before the driver commits the transaction. To learn more about this error, see the - :manual:`TransientTransactionError description - ` on - the Driver API page in the Server manual. -- ``UnknownTransactionCommitResult``: Raised if the commit operation - encounters an error. To learn more about this error, see the - :manual:`UnknownTransactionCommitResult description - ` on - the Driver API page in the Server manual. - -The Convenient Transaction API incorporates retry logic for these error -types, so the driver retries the transaction until there is a successful commit. \ No newline at end of file +Because MongoDB transactions are :website:`ACID compliant +`, the driver might produce errors during operation +to ensure your data maintains consistent. If the following errors occur, your +application must retry the transaction: + +- ``TransientTransactionError``: Raised if a write operation encounters an error + before the driver commits the transaction. To learn more about this error + type, see the :manual:`TransientTransactionError + description ` on + the Drivers API page in the Server manual. +- ``UnknownTransactionCommitResult``: Raised if the commit operation encounters + an error. To learn more about this error type, see the + :manual:`UnknownTransactionCommitResult + description ` + on the Drivers API page in the Server manual. + +The following sections describe how to handle these errors when using different APIs. + +Convenient Transaction API Error Handling +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Convenient Transaction API incorporates retry logic for these error types. +The driver automatically retries the transaction until there is a successful +commit. + +Core API Error Handling +~~~~~~~~~~~~~~~~~~~~~~~ + +If you are using the Core API to perform a transaction, you must add the following +error-handling functions to your application: + +- A function that retries the entire transaction when the driver encounters a + ``TransientTransactionError`` +- A function that retries the commit operation when the driver encounters an + ``UnknownTransactionCommitResult`` + +These functions must run until there is a successful commit or a different +error. For an example of this retry logic, see the :manual:`Core API section +` on the Drivers API page in the +Server manual. \ No newline at end of file