summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2019-07-03 16:02:45 -0400
committerMaria van Keulen <maria@mongodb.com>2019-07-09 10:40:36 -0400
commitec0dd11141b54fb953d87e69be74d37ac86deaa3 (patch)
treeb6689bc3a12cf76bc01a7562235134ceaff2811f
parent52cc03104d09d1b1f9cbfb3bd3a1226e45fc244d (diff)
downloadmongo-ec0dd11141b54fb953d87e69be74d37ac86deaa3.tar.gz
SERVER-41474 Exclude writes to system.profile from Flow Control
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp5
-rw-r--r--src/mongo/db/introspect.cpp13
2 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp
index 5b83d1e9877..68f07b43fd0 100644
--- a/src/mongo/db/commands/dbcommands_d.cpp
+++ b/src/mongo/db/commands/dbcommands_d.cpp
@@ -117,6 +117,11 @@ protected:
int _applyProfilingLevel(OperationContext* opCtx,
const std::string& dbName,
int profilingLevel) const final {
+
+ // The system.profile collection is non-replicated, so writes to it do not cause
+ // replication lag. As such, they should be excluded from Flow Control.
+ opCtx->setShouldParticipateInFlowControl(false);
+
const bool readOnly = (profilingLevel < 0 || profilingLevel > 2);
const LockMode dbMode = readOnly ? MODE_S : MODE_X;
diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp
index 425d100f183..3da10a1a290 100644
--- a/src/mongo/db/introspect.cpp
+++ b/src/mongo/db/introspect.cpp
@@ -121,7 +121,18 @@ void profile(OperationContext* opCtx, NetworkOp op) {
// collection.
bool acquireDbXLock = false;
+ auto origFlowControl = opCtx->shouldParticipateInFlowControl();
+
+ // The system.profile collection is non-replicated, so writes to it do not cause
+ // replication lag. As such, they should be excluded from Flow Control.
+ opCtx->setShouldParticipateInFlowControl(false);
+
+ // IX lock acquisitions beyond this block will not be related to writes to system.profile.
+ ON_BLOCK_EXIT(
+ [opCtx, origFlowControl] { opCtx->setShouldParticipateInFlowControl(origFlowControl); });
+
try {
+
// Even if the operation we are profiling was interrupted, we still want to output the
// profiler entry. This lock guard will prevent lock acquisitions from throwing exceptions
// before we finish writing the entry. However, our maximum lock timeout overrides
@@ -167,6 +178,7 @@ void profile(OperationContext* opCtx, NetworkOp op) {
Collection* const coll = db->getCollection(opCtx, db->getProfilingNS());
if (coll) {
+ invariant(!opCtx->shouldParticipateInFlowControl());
WriteUnitOfWork wuow(opCtx);
OpDebug* const nullOpDebug = nullptr;
coll->insertDocument(opCtx, InsertStatement(p), nullOpDebug, false)
@@ -202,6 +214,7 @@ void profile(OperationContext* opCtx, NetworkOp op) {
Status createProfileCollection(OperationContext* opCtx, Database* db) {
invariant(opCtx->lockState()->isDbLockedForMode(db->name(), MODE_X));
+ invariant(!opCtx->shouldParticipateInFlowControl());
auto& dbProfilingNS = db->getProfilingNS();
Collection* const collection = db->getCollection(opCtx, dbProfilingNS);