summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2020-09-02 20:25:08 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-09 00:40:06 +0000
commit7b2913a64bc8812a9ab71ce27fe14bb2f517376f (patch)
tree5f849520a990cb13080ce28572fb8f3e5601044b /src/mongo
parentb11fe32330deab811a4cfcb190b111c4671148f1 (diff)
downloadmongo-7b2913a64bc8812a9ab71ce27fe14bb2f517376f.tar.gz
SERVER-50116 Forbid oplog writes when replication is enabled
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/ops/insert.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index 383536913e1..fff03006b9f 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -34,6 +34,7 @@
#include "mongo/bson/bson_depth.h"
#include "mongo/db/commands/feature_compatibility_version_parser.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/vector_clock_mutable.h"
#include "mongo/db/views/durable_view_catalog.h"
#include "mongo/util/str.h"
@@ -176,7 +177,9 @@ Status userAllowedWriteNS(const NamespaceString& ns) {
if (ns.isSystemDotProfile() ||
(ns.isSystemDotViews() && serverGlobalParams.featureCompatibility.isVersionInitialized() &&
serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- ServerGlobalParams::FeatureCompatibility::Version::kVersion47))) {
+ ServerGlobalParams::FeatureCompatibility::Version::kVersion47)) ||
+ (ns.isOplog() &&
+ repl::ReplicationCoordinator::get(getGlobalServiceContext())->isReplEnabled())) {
return Status(ErrorCodes::InvalidNamespace, str::stream() << "cannot write to " << ns);
}
return userAllowedCreateNS(ns);