diff options
author | Blake Oler <blake.oler@mongodb.com> | 2018-09-19 13:16:04 -0400 |
---|---|---|
committer | Blake Oler <blake.oler@mongodb.com> | 2018-09-20 22:37:42 -0400 |
commit | 19a5f8726fed990bd75d2a0426f53f691ee82b97 (patch) | |
tree | 87e67161d564ea5fa75a9c58059fccfad6a8fa90 | |
parent | a276b7b1d0cc1d8d1e35bc0a222d2b2cce64bf43 (diff) | |
download | mongo-19a5f8726fed990bd75d2a0426f53f691ee82b97.tar.gz |
SERVER-36831 Report active operations correctly on the ServiceLiaison for mongos
-rw-r--r-- | src/mongo/db/service_liaison_mongos.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/mongo/db/service_liaison_mongos.cpp b/src/mongo/db/service_liaison_mongos.cpp index 2775877ae94..8f687f4f5c7 100644 --- a/src/mongo/db/service_liaison_mongos.cpp +++ b/src/mongo/db/service_liaison_mongos.cpp @@ -44,16 +44,35 @@ LogicalSessionIdSet ServiceLiaisonMongos::getActiveOpSessions() const { invariant(hasGlobalServiceContext()); - // Append any in-use session ids from the global cluster cursor managers. - auto cursorManager = Grid::get(getGlobalServiceContext())->getCursorManager(); - cursorManager->appendActiveSessions(&activeSessions); - + // Walk through the service context and append lsids for all currently-running ops. + for (ServiceContext::LockedClientsCursor cursor(getGlobalServiceContext()); + Client* client = cursor.next();) { + + stdx::lock_guard<Client> lk(*client); + auto clientOpCtx = client->getOperationContext(); + + // Ignore clients without currently-running operations + if (!clientOpCtx) + continue; + + // Append this op ctx's session to our list, if it has one + auto lsid = clientOpCtx->getLogicalSessionId(); + if (lsid) { + activeSessions.insert(*lsid); + } + } return activeSessions; } LogicalSessionIdSet ServiceLiaisonMongos::getOpenCursorSessions() const { LogicalSessionIdSet openCursorSessions; + invariant(hasGlobalServiceContext()); + + // Append any in-use session ids from the global cluster cursor managers. + auto cursorManager = Grid::get(getGlobalServiceContext())->getCursorManager(); + cursorManager->appendActiveSessions(&openCursorSessions); + return openCursorSessions; } |