summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2019-10-24 18:06:47 +0000
committerevergreen <evergreen@mongodb.com>2019-10-24 18:06:47 +0000
commit55e80afa2d511b9bd1a316d3fd4cb6185baa829b (patch)
tree8f4d6241aee47c4fb7127a935895fdbf8548e13e
parent2b6f5ce734f834ca73d0fbe9da162c0ab43a5345 (diff)
downloadmongo-55e80afa2d511b9bd1a316d3fd4cb6185baa829b.tar.gz
SERVER-43236 Wrap reconfig cmd no-op oplog write in writeConflictRetry block
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index ee1f49396a1..a9c7bdc5336 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -46,6 +46,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"
@@ -75,6 +76,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") {}
@@ -394,17 +397,19 @@ public:
if (status.isOK() && !parsedArgs.force) {
const auto service = opCtx->getServiceContext();
-
Lock::GlobalLock globalLock(opCtx, MODE_IX);
- 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.
- service->getOpObserver()->onOpMessage(opCtx,
- BSON("msg"
- << "Reconfig set"
- << "version"
- << parsedArgs.newConfigObj["version"]));
- wuow.commit();
+ 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.
+
+ service->getOpObserver()->onOpMessage(opCtx,
+ BSON("msg"
+ << "Reconfig set"
+ << "version"
+ << parsedArgs.newConfigObj["version"]));
+ wuow.commit();
+ });
}
uassertStatusOK(status);