Skip to content

Commit

Permalink
fix(serverSelection): make sure to pass session to serverSelection
Browse files Browse the repository at this point in the history
The executeWithSelection changes failed to pass the session to
server selection, which broke mongos pinning. This ensures that
we pass a session to serverSelection.
  • Loading branch information
daprahamian committed Aug 13, 2019
1 parent 083e18a commit eb5cc6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/operations/execute_operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ function executeWithServerSelection(topology, operation, callback) {
return;
}

const serverSelectionOptions = {
readPreference,
session: operation.session
};

function callbackWithRetry(err, result) {
if (err == null) {
return callback(null, result);
Expand All @@ -142,7 +147,7 @@ function executeWithServerSelection(topology, operation, callback) {
}

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

// select a server, and execute the operation against it
topology.selectServer(readPreference, (err, server) => {
topology.selectServer(serverSelectionOptions, (err, server) => {
if (err) {
callback(err, null);
return;
Expand Down

0 comments on commit eb5cc6b

Please sign in to comment.