summaryrefslogtreecommitdiff
path: root/src/mongo/db/introspect.cpp
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 /src/mongo/db/introspect.cpp
parent52cc03104d09d1b1f9cbfb3bd3a1226e45fc244d (diff)
downloadmongo-ec0dd11141b54fb953d87e69be74d37ac86deaa3.tar.gz
SERVER-41474 Exclude writes to system.profile from Flow Control
Diffstat (limited to 'src/mongo/db/introspect.cpp')
-rw-r--r--src/mongo/db/introspect.cpp13
1 files changed, 13 insertions, 0 deletions
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);