diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2018-03-21 21:08:20 +0000 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2018-03-22 03:36:43 +0000 |
commit | 40d59f4bc8eec0fc585edec0f2c8833f09a4a853 (patch) | |
tree | f5654a7274c4925ad3be8d46e305f8478894c445 /src/mongo/s/service_entry_point_mongos.cpp | |
parent | b7178eca18c1a56b05eb206fa9d202345c128df5 (diff) | |
download | mongo-40d59f4bc8eec0fc585edec0f2c8833f09a4a853.tar.gz |
SERVER-14900 Log operations that exceed slowMs on mongoS
Diffstat (limited to 'src/mongo/s/service_entry_point_mongos.cpp')
-rw-r--r-- | src/mongo/s/service_entry_point_mongos.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/s/service_entry_point_mongos.cpp b/src/mongo/s/service_entry_point_mongos.cpp index dc1f8312b97..7b2c10fbc9b 100644 --- a/src/mongo/s/service_entry_point_mongos.cpp +++ b/src/mongo/s/service_entry_point_mongos.cpp @@ -34,6 +34,7 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/commands.h" +#include "mongo/db/curop.h" #include "mongo/db/dbmessage.h" #include "mongo/db/lasterror.h" #include "mongo/db/operation_context.h" @@ -84,12 +85,20 @@ DbResponse ServiceEntryPointMongos::handleRequest(OperationContext* opCtx, const LastError::get(client).startRequest(); AuthorizationSession::get(opCtx->getClient())->startRequest(opCtx); + CurOp::get(opCtx)->ensureStarted(); + DbMessage dbm(message); // This is before the try block since it handles all exceptions that should not cause the // connection to close. if (op == dbMsg || (op == dbQuery && NamespaceString(dbm.getns()).isCommand())) { - return Strategy::clientCommand(opCtx, message); + auto dbResponse = Strategy::clientCommand(opCtx, message); + + // Mark the op as complete, populate the response length, and log it if appropriate. + CurOp::get(opCtx)->completeAndLogOperation( + opCtx, logger::LogComponent::kCommand, dbResponse.response.size()); + + return dbResponse; } NamespaceString nss; @@ -151,7 +160,13 @@ DbResponse ServiceEntryPointMongos::handleRequest(OperationContext* opCtx, const // We *always* populate the last error for now LastError::get(opCtx->getClient()).setLastError(ex.code(), ex.what()); + CurOp::get(opCtx)->debug().errInfo = ex.toStatus(); } + + // Mark the op as complete, populate the response length, and log it if appropriate. + CurOp::get(opCtx)->completeAndLogOperation( + opCtx, logger::LogComponent::kCommand, dbResponse.response.size()); + return dbResponse; } |