summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index dc8c481cd62..91ed0a74125 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/server_status_metric.h"
+#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/op_observer.h"
@@ -77,6 +78,8 @@ namespace repl {
using std::string;
using std::stringstream;
+static const std::string kReplSetReconfigNss = "local.replset.reconfig";
+
class ReplExecutorSSM : public ServerStatusMetric {
public:
ReplExecutorSSM() : ServerStatusMetric("repl.executor") {}
@@ -433,20 +436,22 @@ public:
status =
getGlobalReplicationCoordinator()->processReplSetReconfig(opCtx, parsedArgs, &result);
- Lock::GlobalWrite globalWrite(opCtx);
-
- WriteUnitOfWork wuow(opCtx);
if (status.isOK() && !parsedArgs.force) {
- // Users must not be allowed to provide their own contents for the o2 field.
- // o2 field of no-ops is supposed to be used internally.
- getGlobalServiceContext()->getOpObserver()->onOpMessage(
- opCtx,
- BSON("msg"
- << "Reconfig set"
- << "version"
- << parsedArgs.newConfigObj["version"]));
+ Lock::GlobalWrite globalWrite(opCtx);
+ writeConflictRetry(
+ opCtx, "replSetReconfig", kReplSetReconfigNss, [&] {
+ WriteUnitOfWork wuow(opCtx);
+ // Users must not be allowed to provide their own contents for the o2 field.
+ // o2 field of no-ops is supposed to be used internally.
+ getGlobalServiceContext()->getOpObserver()->onOpMessage(
+ opCtx,
+ BSON("msg"
+ << "Reconfig set"
+ << "version"
+ << parsedArgs.newConfigObj["version"]));
+ wuow.commit();
+ });
}
- wuow.commit();
return appendCommandStatus(result, status);
}