Skip to content

Commit

Permalink
DRIVERS-2695 Add a case of CSOT not enabled for the retryable writes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Oct 19, 2023
1 parent 3c7d132 commit d1157f7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions source/retryable-writes/retryable-writes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -468,7 +469,7 @@ The above rules are implemented in the following pseudo-code:
* numbers" MUST be re-raised with an actionable error message.
*/
if (!currentError.hasErrorLabel("RetryableWriteError")) {
if ( currentError.code == 20 && originalError.errmsg.startsWith("Transaction numbers") ) {
if ( currentError.code == 20 && previousError.errmsg.startsWith("Transaction numbers") ) {
currentError.errmsg = "This MongoDB deployment does not support retryable...";
}
throw currentError;
Expand All @@ -490,7 +491,7 @@ The above rules are implemented in the following pseudo-code:
* from the connection pool), we should raise the previous error if there
* was one.
*/
if (currentError is not DriverException && ! originalError.hasErrorLabel("NoWritesPerformed")) {
if (currentError is not DriverException && ! previousError.hasErrorLabel("NoWritesPerformed")) {
previousError = currentError;
}
}
Expand All @@ -516,10 +517,18 @@ The above rules are implemented in the following pseudo-code:
throw previousError;
}
/* CSOT is enabled and the operation has timed out. */
if (timeoutMS != null && isExpired(timeoutMS) {
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. */
if (retrying) {
throw previousError;
}
} else if (isExpired(timeoutMS)) {
/* CSOT is enabled and the operation has timed out. */
throw previousError;
}
retrying = true;
}
}
Expand Down Expand Up @@ -829,6 +838,7 @@ inconsistent with the server and potentially confusing to developers.
Changelog
=========

:2023-10-02: When CSOT is not enabled, one retry attempt occurs.
:2023-08-26: Require that in a sharded cluster the server on which the
operation failed MUST be provided to the server selection
mechanism as a deprioritized server.
Expand Down

0 comments on commit d1157f7

Please sign in to comment.