summaryrefslogtreecommitdiff
path: root/src/mongo/transport/service_state_machine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/transport/service_state_machine.cpp')
-rw-r--r--src/mongo/transport/service_state_machine.cpp47
1 files changed, 36 insertions, 11 deletions
diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp
index 4ca997d96ed..041d2fdb715 100644
--- a/src/mongo/transport/service_state_machine.cpp
+++ b/src/mongo/transport/service_state_machine.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/dbmessage.h"
#include "mongo/db/stats/counters.h"
#include "mongo/db/traffic_recorder.h"
+#include "mongo/logv2/log.h"
#include "mongo/rpc/message.h"
#include "mongo/rpc/op_msg.h"
#include "mongo/transport/message_compressor_manager.h"
@@ -375,16 +376,27 @@ void ServiceStateMachine::_sourceCallback(Status status) {
transport::ServiceExecutorTaskName::kSSMProcessMessage);
} else if (ErrorCodes::isInterruption(status.code()) ||
ErrorCodes::isNetworkError(status.code())) {
- LOG(2) << "Session from " << remote
- << " encountered a network error during SourceMessage: " << status;
+ LOGV2_DEBUG(
+ 22986,
+ 2,
+ "Session from {remote} encountered a network error during SourceMessage: {status}",
+ "remote"_attr = remote,
+ "status"_attr = status);
_state.store(State::EndSession);
} else if (status == TransportLayer::TicketSessionClosedStatus) {
// Our session may have been closed internally.
- LOG(2) << "Session from " << remote << " was closed internally during SourceMessage";
+ LOGV2_DEBUG(22987,
+ 2,
+ "Session from {remote} was closed internally during SourceMessage",
+ "remote"_attr = remote);
_state.store(State::EndSession);
} else {
- log() << "Error receiving request from client: " << status << ". Ending connection from "
- << remote << " (connection id: " << _session()->id() << ")";
+ LOGV2(22988,
+ "Error receiving request from client: {status}. Ending connection from {remote} "
+ "(connection id: {session_id})",
+ "status"_attr = status,
+ "remote"_attr = remote,
+ "session_id"_attr = _session()->id());
_state.store(State::EndSession);
}
@@ -406,8 +418,12 @@ void ServiceStateMachine::_sinkCallback(Status status) {
// Otherwise, update the current state depending on whether we're in exhaust or not, and call
// scheduleNext() to unwind the stack and do the next step.
if (!status.isOK()) {
- log() << "Error sending response to client: " << status << ". Ending connection from "
- << _session()->remote() << " (connection id: " << _session()->id() << ")";
+ LOGV2(22989,
+ "Error sending response to client: {status}. Ending connection from {session_remote} "
+ "(connection id: {session_id})",
+ "status"_attr = status,
+ "session_remote"_attr = _session()->remote(),
+ "session_id"_attr = _session()->id());
_state.store(State::EndSession);
return _runNextInGuard(std::move(guard));
} else if (_inExhaust) {
@@ -540,7 +556,9 @@ void ServiceStateMachine::_runNextInGuard(ThreadGuard guard) {
return;
} catch (const DBException& e) {
- log() << "DBException handling request, closing client connection: " << redact(e);
+ LOGV2(22990,
+ "DBException handling request, closing client connection: {e}",
+ "e"_attr = redact(e));
}
// No need to catch std::exception, as std::terminate will be called when the exception bubbles
// to the top of the stack
@@ -604,7 +622,9 @@ void ServiceStateMachine::terminateIfTagsDontMatch(transport::Session::TagMask t
// If terminateIfTagsDontMatch gets called when we still are 'pending' where no tags have been
// set, then skip the termination check.
if ((sessionTags & tags) || (sessionTags & transport::Session::kPending)) {
- log() << "Skip closing connection for connection # " << _session()->id();
+ LOGV2(22991,
+ "Skip closing connection for connection # {session_id}",
+ "session_id"_attr = _session()->id());
return;
}
@@ -622,7 +642,10 @@ ServiceStateMachine::State ServiceStateMachine::state() {
void ServiceStateMachine::_terminateAndLogIfError(Status status) {
if (!status.isOK()) {
- warning(logger::LogComponent::kExecutor) << "Terminating session due to error: " << status;
+ LOGV2_WARNING_OPTIONS(22993,
+ {logComponentV1toV2(logger::LogComponent::kExecutor)},
+ "Terminating session due to error: {status}",
+ "status"_attr = status);
terminate();
}
}
@@ -642,7 +665,9 @@ void ServiceStateMachine::_cleanupExhaustResources() noexcept try {
_sep->handleRequest(opCtx.get(), makeKillCursorsMessage(cursorId));
}
} catch (const DBException& e) {
- log() << "Error cleaning up resources for exhaust requests: " << e.toStatus();
+ LOGV2(22992,
+ "Error cleaning up resources for exhaust requests: {e_toStatus}",
+ "e_toStatus"_attr = e.toStatus());
}
void ServiceStateMachine::_cleanupSession(ThreadGuard guard) {