summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_current_op.cpp
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@gmail.com>2018-03-28 19:00:18 +0100
committerBernard Gorman <bernard.gorman@gmail.com>2018-04-05 03:05:56 +0100
commit75160508e02cb5051f554baff3e67f2adb316057 (patch)
treefdf97c30fdcd0ec172470f43f4cc4aa6b66dcdb1 /src/mongo/db/pipeline/document_source_current_op.cpp
parentf00b908d2bf6cca4c2527eaa88b0ae79d745fd0b (diff)
downloadmongo-75160508e02cb5051f554baff3e67f2adb316057.tar.gz
SERVER-33294 Report stashed in-use locks for idle sessions in currentOp
Diffstat (limited to 'src/mongo/db/pipeline/document_source_current_op.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_current_op.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/document_source_current_op.cpp b/src/mongo/db/pipeline/document_source_current_op.cpp
index 5d9eb824adf..3c982d53487 100644
--- a/src/mongo/db/pipeline/document_source_current_op.cpp
+++ b/src/mongo/db/pipeline/document_source_current_op.cpp
@@ -37,6 +37,7 @@ namespace mongo {
namespace {
const StringData kAllUsersFieldName = "allUsers"_sd;
const StringData kIdleConnectionsFieldName = "idleConnections"_sd;
+const StringData kIdleSessionsFieldName = "idleSessions"_sd;
const StringData kLocalOpsFieldName = "localOps"_sd;
const StringData kTruncateOpsFieldName = "truncateOps"_sd;
@@ -108,8 +109,11 @@ DocumentSource::GetNextResult DocumentSourceCurrentOp::getNext() {
pExpCtx->checkForInterrupt();
if (_ops.empty()) {
- _ops = pExpCtx->mongoProcessInterface->getCurrentOps(
- pExpCtx->opCtx, _includeIdleConnections, _includeOpsFromAllUsers, _truncateOps);
+ _ops = pExpCtx->mongoProcessInterface->getCurrentOps(pExpCtx->opCtx,
+ _includeIdleConnections,
+ _includeIdleSessions,
+ _includeOpsFromAllUsers,
+ _truncateOps);
_opsIter = _ops.begin();
@@ -180,6 +184,7 @@ intrusive_ptr<DocumentSource> DocumentSourceCurrentOp::createFromBson(
nss.db() == NamespaceString::kAdminDb && nss.isCollectionlessAggregateNS());
ConnMode includeIdleConnections = ConnMode::kExcludeIdle;
+ SessionMode includeIdleSessions = SessionMode::kIncludeIdle;
UserMode includeOpsFromAllUsers = UserMode::kExcludeOthers;
LocalOpsMode showLocalOpsOnMongoS = LocalOpsMode::kRemoteShardOps;
TruncationMode truncateOps = TruncationMode::kNoTruncation;
@@ -195,6 +200,15 @@ intrusive_ptr<DocumentSource> DocumentSourceCurrentOp::createFromBson(
elem.type() == BSONType::Bool);
includeIdleConnections =
(elem.boolean() ? ConnMode::kIncludeIdle : ConnMode::kExcludeIdle);
+ } else if (fieldName == kIdleSessionsFieldName) {
+ uassert(
+ ErrorCodes::FailedToParse,
+ str::stream() << "The 'idleSessions' parameter of the $currentOp stage must be a "
+ "boolean value, but found: "
+ << typeName(elem.type()),
+ elem.type() == BSONType::Bool);
+ includeIdleSessions =
+ (elem.boolean() ? SessionMode::kIncludeIdle : SessionMode::kExcludeIdle);
} else if (fieldName == kAllUsersFieldName) {
uassert(ErrorCodes::FailedToParse,
str::stream() << "The 'allUsers' parameter of the $currentOp stage must be a "
@@ -226,18 +240,27 @@ intrusive_ptr<DocumentSource> DocumentSourceCurrentOp::createFromBson(
}
}
- return new DocumentSourceCurrentOp(
- pExpCtx, includeIdleConnections, includeOpsFromAllUsers, showLocalOpsOnMongoS, truncateOps);
+ return new DocumentSourceCurrentOp(pExpCtx,
+ includeIdleConnections,
+ includeIdleSessions,
+ includeOpsFromAllUsers,
+ showLocalOpsOnMongoS,
+ truncateOps);
}
intrusive_ptr<DocumentSourceCurrentOp> DocumentSourceCurrentOp::create(
const boost::intrusive_ptr<ExpressionContext>& pExpCtx,
ConnMode includeIdleConnections,
+ SessionMode includeIdleSessions,
UserMode includeOpsFromAllUsers,
LocalOpsMode showLocalOpsOnMongoS,
TruncationMode truncateOps) {
- return new DocumentSourceCurrentOp(
- pExpCtx, includeIdleConnections, includeOpsFromAllUsers, showLocalOpsOnMongoS, truncateOps);
+ return new DocumentSourceCurrentOp(pExpCtx,
+ includeIdleConnections,
+ includeIdleSessions,
+ includeOpsFromAllUsers,
+ showLocalOpsOnMongoS,
+ truncateOps);
}
Value DocumentSourceCurrentOp::serialize(boost::optional<ExplainOptions::Verbosity> explain) const {
@@ -245,6 +268,8 @@ Value DocumentSourceCurrentOp::serialize(boost::optional<ExplainOptions::Verbosi
{getSourceName(),
Document{{kIdleConnectionsFieldName,
_includeIdleConnections == ConnMode::kIncludeIdle ? Value(true) : Value()},
+ {kIdleSessionsFieldName,
+ _includeIdleSessions == SessionMode::kExcludeIdle ? Value(false) : Value()},
{kAllUsersFieldName,
_includeOpsFromAllUsers == UserMode::kIncludeAll ? Value(true) : Value()},
{kLocalOpsFieldName,