summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2019-11-06 19:51:46 +0000
committerevergreen <evergreen@mongodb.com>2019-11-06 19:51:46 +0000
commit0d5240e8af0e9aa7c29c45138f6054c761a2a178 (patch)
tree592f8806ab3aa2e2d1c742ec744764647fe1c06b
parent4777454d75eb8e6a592dbd988e90336decd64baa (diff)
downloadmongo-0d5240e8af0e9aa7c29c45138f6054c761a2a178.tar.gz
SERVER-43236 Wrap reconfig cmd no-op oplog write in writeConflictRetry block
(cherry picked from commit 55e80afa2d511b9bd1a316d3fd4cb6185baa829b)
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index 48f9c96f4e7..f660095d15c 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -48,6 +48,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/commands/test_commands_enabled.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") {}
@@ -386,21 +389,22 @@ public:
status =
ReplicationCoordinator::get(opCtx)->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();
-
uassertStatusOK(status);
return true;
}