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

Commit 7ac171e

Browse files
authored
fix(retryableWrites): only remove primary after retry (#274)
Make sure to not remove the primary on an error until after the retry
1 parent 8c4a0ef commit 7ac171e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/topologies/replset.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,14 +1212,14 @@ function executeWriteOperation(args, options, callback) {
12121212
return callback(err);
12131213
}
12141214

1215-
// Per SDAM, remove primary from replicaset
1216-
self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true });
1217-
12181215
if (willRetryWrite) {
12191216
const newArgs = Object.assign({}, args, { retrying: true });
12201217
return executeWriteOperation(newArgs, options, callback);
12211218
}
12221219

1220+
// Per SDAM, remove primary from replicaset
1221+
self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true });
1222+
12231223
return callback(err);
12241224
};
12251225

0 commit comments

Comments
 (0)