diff options
author | Ali Mir <ali.mir@mongodb.com> | 2019-11-06 23:24:42 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-06 23:24:42 +0000 |
commit | 43f4a99347f17c73b9502cba88e4214a28a0005d (patch) | |
tree | 6846651a7c6339d608ed4f9ae41210c9198019e4 /src | |
parent | eb4aa4f9e7c4cb4f14fe278882480a6b5f92b105 (diff) | |
download | mongo-43f4a99347f17c73b9502cba88e4214a28a0005d.tar.gz |
SERVER-43236 Wrap reconfig cmd no-op oplog write in writeConflictRetry block
(cherry picked from commit 55e80afa2d511b9bd1a316d3fd4cb6185baa829b)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/repl_set_commands.cpp | 29 |
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); } |