Skip to content

Commit 3913eaa

Browse files
mbroadstdaprahamian
authored andcommitted
refactor: ensure selected server in retry supports retryable reads
1 parent 360975a commit 3913eaa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/operations/execute_operation.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ function executeOperation(topology, operation, callback) {
9494
});
9595
}
9696

97+
function supportsRetryableReads(server) {
98+
return maxWireVersion(server) >= 6;
99+
}
100+
97101
function executeWithServerSelection(topology, operation, callback) {
98102
const readPreference = operation.readPreference || ReadPreference.primary;
99103

@@ -108,7 +112,7 @@ function executeWithServerSelection(topology, operation, callback) {
108112

109113
// select a new server, and attempt to retry the operation
110114
topology.selectServer(readPreference, (err, server) => {
111-
if (err) {
115+
if (err || !supportsRetryableReads(server)) {
112116
callback(err, null);
113117
return;
114118
}
@@ -127,7 +131,7 @@ function executeWithServerSelection(topology, operation, callback) {
127131
const shouldRetryReads =
128132
topology.s.options.retryReads !== false &&
129133
(operation.session && !operation.session.inTransaction()) &&
130-
maxWireVersion(server) >= 6;
134+
supportsRetryableReads(server);
131135

132136
if (operation.hasAspect(Aspect.RETRYABLE) && shouldRetryReads) {
133137
operation.execute(server, callbackWithRetry);

0 commit comments

Comments
 (0)