Skip to content

Commit 022fbf6

Browse files
authored
DRIVERS-2764 Fix error in retryable read pusedocode when CSOT is not enabled (#1472)
1 parent f98dc36 commit 022fbf6

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

source/retryable-reads/retryable-reads.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,12 @@ and reflects the flow described above.
360360
*/
361361
function executeRetryableRead(command, session) {
362362
Exception previousError = null;
363+
retrying = false;
363364
Server previousServer = null;
364365
while true {
366+
if (previousError != null) {
367+
retrying = true;
368+
}
365369
try {
366370
if (previousServer == null) {
367371
server = selectServer();
@@ -438,8 +442,16 @@ and reflects the flow described above.
438442
}
439443
throw error;
440444
}
441-
/* CSOT is enabled and the operation has timed out. */
442-
if (timeoutMS != null && isExpired(timeoutMS) {
445+
446+
if (timeoutMS == null) {
447+
/* If CSOT is not enabled, allow any retryable error from the second
448+
* attempt to propagate to our caller, as it will be just as relevant
449+
* (if not more relevant) than the original error. */
450+
if (retrying) {
451+
throw previousError;
452+
}
453+
} else if (isExpired(timeoutMS)) {
454+
/* CSOT is enabled and the operation has timed out. */
443455
throw previousError;
444456
}
445457
}

0 commit comments

Comments
 (0)