From efc2bfc46a17ee7be4cd6ec4c1eb7c440be04c45 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Mon, 16 Oct 2023 11:19:05 -0400 Subject: [PATCH] DRIVERS-2695 Correct the error propagation logic. --- source/retryable-writes/retryable-writes.rst | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source/retryable-writes/retryable-writes.rst b/source/retryable-writes/retryable-writes.rst index 8cf59401fa..b1604d8c14 100644 --- a/source/retryable-writes/retryable-writes.rst +++ b/source/retryable-writes/retryable-writes.rst @@ -455,6 +455,7 @@ The above rules are implemented in the following pseudo-code: retryableCommand = addTransactionIdToCommand(command, session); Exception previousError = null; + retrying = false; while true { try { return executeCommand(server, retryableCommand); @@ -519,23 +520,15 @@ The above rules are implemented in the following pseudo-code: if (timeoutMS == null) { /* If CSOT is not enabled, allow any retryable error from the second * attempt to propagate to our caller, as it will be just as relevant - * (if not more relevant) than the original error. For exceptions that - * originate from the driver, we should raise the previous error. Other - * exceptions originating from the server should be allowed to - * propagate. */ - try { - return executeCommand(server, retryableCommand); - } catch (DriverException ignoredError) { + * (if not more relevant) than the original error. */ + if (retrying) { throw previousError; - } catch (Exception secondError) { - handleError(secondError); - throw secondError; } - break } else if (isExpired(timeoutMS)) { /* CSOT is enabled and the operation has timed out. */ throw previousError; } + retrying = true; } }