Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(retryableWrites): only remove primary after retry (#274)
Browse files Browse the repository at this point in the history
Make sure to not remove the primary on an error until after the
retry
  • Loading branch information
daprahamian committed Feb 2, 2018
1 parent 8c4a0ef commit 7ac171e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/topologies/replset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1212,14 +1212,14 @@ function executeWriteOperation(args, options, callback) {
return callback(err);
}

// Per SDAM, remove primary from replicaset
self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true });

if (willRetryWrite) {
const newArgs = Object.assign({}, args, { retrying: true });
return executeWriteOperation(newArgs, options, callback);
}

// Per SDAM, remove primary from replicaset
self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true });

return callback(err);
};

Expand Down

0 comments on commit 7ac171e

Please sign in to comment.