Skip to content

Commit eb5cc6b

Browse files
committed
fix(serverSelection): make sure to pass session to serverSelection
The executeWithSelection changes failed to pass the session to server selection, which broke mongos pinning. This ensures that we pass a session to serverSelection.
1 parent 083e18a commit eb5cc6b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/operations/execute_operation.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ function executeWithServerSelection(topology, operation, callback) {
132132
return;
133133
}
134134

135+
const serverSelectionOptions = {
136+
readPreference,
137+
session: operation.session
138+
};
139+
135140
function callbackWithRetry(err, result) {
136141
if (err == null) {
137142
return callback(null, result);
@@ -142,7 +147,7 @@ function executeWithServerSelection(topology, operation, callback) {
142147
}
143148

144149
// select a new server, and attempt to retry the operation
145-
topology.selectServer(readPreference, (err, server) => {
150+
topology.selectServer(serverSelectionOptions, (err, server) => {
146151
if (err || !supportsRetryableReads(server)) {
147152
callback(err, null);
148153
return;
@@ -153,7 +158,7 @@ function executeWithServerSelection(topology, operation, callback) {
153158
}
154159

155160
// select a server, and execute the operation against it
156-
topology.selectServer(readPreference, (err, server) => {
161+
topology.selectServer(serverSelectionOptions, (err, server) => {
157162
if (err) {
158163
callback(err, null);
159164
return;

0 commit comments

Comments
 (0)