summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-05-23 14:30:34 -0400
committerBenety Goh <benety@mongodb.com>2017-05-23 14:30:34 -0400
commit56fb4fa3f7813baeebec179905dd98f9dcc30310 (patch)
treeee39fbc501dcdcc9e88c130e799e86afd38e1c61 /src/mongo
parent3bb7318a5b5c8d4a07696ab1dd292fe5b9077924 (diff)
downloadmongo-56fb4fa3f7813baeebec179905dd98f9dcc30310.tar.gz
Revert "SERVER-29274 move oplogDisabled from oplog.cpp to ReplicationCoordinator"
This reverts commit c1b1bd0944115c30b18bfe189356897e8896012f.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/oplog.cpp37
-rw-r--r--src/mongo/db/repl/replication_coordinator.cpp23
-rw-r--r--src/mongo/db/repl/replication_coordinator.h6
3 files changed, 28 insertions, 38 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index f5879566095..ba4db896335 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -249,6 +249,26 @@ Collection* getLocalOplogCollection(OperationContext* opCtx,
return _localOplogCollection;
}
+bool oplogDisabled(OperationContext* opCtx,
+ ReplicationCoordinator::Mode replicationMode,
+ const NamespaceString& nss) {
+ if (replicationMode == ReplicationCoordinator::modeNone)
+ return true;
+
+ if (nss.db() == "local")
+ return true;
+
+ if (nss.isSystemDotProfile())
+ return true;
+
+ if (!opCtx->writesAreReplicated())
+ return true;
+
+ fassert(28626, opCtx->recoveryUnit());
+
+ return false;
+}
+
OplogDocWriter _logOpWriter(OperationContext* opCtx,
const char* opstr,
const NamespaceString& nss,
@@ -377,15 +397,15 @@ void logOp(OperationContext* opCtx,
const BSONObj& obj,
const BSONObj* o2,
bool fromMigrate) {
- auto replCoord = ReplicationCoordinator::get(opCtx);
- if (replCoord->isOplogDisabledFor(opCtx, nss)) {
+ ReplicationCoordinator::Mode replMode =
+ ReplicationCoordinator::get(opCtx)->getReplicationMode();
+ if (oplogDisabled(opCtx, replMode, nss))
return;
- }
+ ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
Collection* oplog = getLocalOplogCollection(opCtx, _oplogCollectionName);
Lock::DBLock lk(opCtx, "local", MODE_IX);
Lock::CollectionLock lock(opCtx->lockState(), _oplogCollectionName, MODE_IX);
- auto replMode = replCoord->getReplicationMode();
OplogSlot slot;
getNextOpTime(opCtx, oplog, replCoord, replMode, 1, &slot);
auto writer =
@@ -401,12 +421,12 @@ void logOps(OperationContext* opCtx,
std::vector<BSONObj>::const_iterator begin,
std::vector<BSONObj>::const_iterator end,
bool fromMigrate) {
- invariant(begin != end);
+ ReplicationCoordinator* replCoord = ReplicationCoordinator::get(opCtx);
+ ReplicationCoordinator::Mode replMode = replCoord->getReplicationMode();
- auto replCoord = ReplicationCoordinator::get(opCtx);
- if (replCoord->isOplogDisabledFor(opCtx, nss)) {
+ invariant(begin != end);
+ if (oplogDisabled(opCtx, replMode, nss))
return;
- }
const size_t count = end - begin;
std::vector<OplogDocWriter> writers;
@@ -415,7 +435,6 @@ void logOps(OperationContext* opCtx,
Lock::DBLock lk(opCtx, "local", MODE_IX);
Lock::CollectionLock lock(opCtx->lockState(), _oplogCollectionName, MODE_IX);
std::unique_ptr<OplogSlot[]> slots(new OplogSlot[count]);
- auto replMode = replCoord->getReplicationMode();
getNextOpTime(opCtx, oplog, replCoord, replMode, count, slots.get());
for (size_t i = 0; i < count; i++) {
writers.emplace_back(_logOpWriter(
diff --git a/src/mongo/db/repl/replication_coordinator.cpp b/src/mongo/db/repl/replication_coordinator.cpp
index d9f5c3fe82a..27ba1b39dda 100644
--- a/src/mongo/db/repl/replication_coordinator.cpp
+++ b/src/mongo/db/repl/replication_coordinator.cpp
@@ -67,28 +67,5 @@ void ReplicationCoordinator::set(ServiceContext* service,
coordinator = std::move(replCoord);
}
-bool ReplicationCoordinator::isOplogDisabledFor(OperationContext* opCtx,
- const NamespaceString& nss) {
- if (getReplicationMode() == ReplicationCoordinator::modeNone) {
- return true;
- }
-
- if (nss.db() == "local") {
- return true;
- }
-
- if (nss.isSystemDotProfile()) {
- return true;
- }
-
- if (!opCtx->writesAreReplicated()) {
- return true;
- }
-
- fassert(28626, opCtx->recoveryUnit());
-
- return false;
-}
-
} // namespace repl
} // namespace mongo
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index d682ee756be..a9ccd9f642a 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -875,12 +875,6 @@ public:
*/
virtual Status abortCatchupIfNeeded() = 0;
- /**
- * Returns true if logOp() should not append an entry to the oplog for the namespace for this
- * operation.
- */
- bool isOplogDisabledFor(OperationContext* opCtx, const NamespaceString& nss);
-
protected:
ReplicationCoordinator();
};