Skip to content

Commit

Permalink
DRIVERS-2764 Fix error in retryable read pusedocode when CSOT is not …
Browse files Browse the repository at this point in the history
…enabled (#1472)
  • Loading branch information
ShaneHarvey committed Nov 8, 2023
1 parent f98dc36 commit 022fbf6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/retryable-reads/retryable-reads.rst
Expand Up @@ -360,8 +360,12 @@ and reflects the flow described above.
*/
function executeRetryableRead(command, session) {
Exception previousError = null;
retrying = false;
Server previousServer = null;
while true {
if (previousError != null) {
retrying = true;
}
try {
if (previousServer == null) {
server = selectServer();
Expand Down Expand Up @@ -438,8 +442,16 @@ and reflects the flow described above.
}
throw error;
}
/* 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;
}
}
Expand Down

0 comments on commit 022fbf6

Please sign in to comment.