From 90d3ce821b6faa28c68b515bfacb4ce63388759d Mon Sep 17 00:00:00 2001 From: Misha Tyulenev Date: Fri, 28 Feb 2020 14:59:17 -0500 Subject: SERVER-46463 add logging for hedged reads --- src/mongo/executor/network_interface_tl.cpp | 15 ++++++++++++++- src/mongo/executor/network_interface_tl.h | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp index afe86fa7ae7..76ff8e8cc7d 100644 --- a/src/mongo/executor/network_interface_tl.cpp +++ b/src/mongo/executor/network_interface_tl.cpp @@ -334,12 +334,14 @@ void NetworkInterfaceTL::RequestState::returnConnection(Status status) noexcept void NetworkInterfaceTL::CommandStateBase::tryFinish(Status status) noexcept { invariant(finishLine.isReady()); + LOGV2_DEBUG(4646302, 2, "Finished request {request_id}", "request_id"_attr = requestOnAny.id); + if (timer) { // The command has resolved one way or another, timer->cancel(baton); } - if (!status.isOK()) { + if (!status.isOK()) { // TODO: SERVER-46469: || (requestManager && requestManager->isHedging)) if (requestManager) { requestManager->cancelRequests(); } @@ -552,6 +554,11 @@ void NetworkInterfaceTL::RequestManager::cancelRequests() { for (size_t i = 0; i < requests.size(); i++) { auto requestState = requests[i].lock(); if (requestState) { + LOGV2_DEBUG(4646301, + 2, + "Cancelling request {request_id} with index {idx}", + "request_id"_attr = cmdState.lock()->requestOnAny.id, + "idx"_attr = i); requestState->cancel(); } } @@ -594,6 +601,12 @@ void NetworkInterfaceTL::RequestManager::trySend( } } + LOGV2_DEBUG(4646300, + 2, + "Sending request {request_id} with index {idx}", + "request_id"_attr = cmdState.lock()->requestOnAny.id, + "idx"_attr = idx); + auto req = getNextRequest(); if (req) { req->send(std::move(swConn), {cmdStatePtr->requestOnAny, idx}); diff --git a/src/mongo/executor/network_interface_tl.h b/src/mongo/executor/network_interface_tl.h index fc4d40c194d..9d599452af3 100644 --- a/src/mongo/executor/network_interface_tl.h +++ b/src/mongo/executor/network_interface_tl.h @@ -211,7 +211,8 @@ private: RequestManager(size_t numHedges, std::shared_ptr cmdState_) : connStatus(cmdState_->requestOnAny.target.size(), ConnStatus::Unset), requests(numHedges), - cmdState(cmdState_) {} + cmdState(cmdState_), + isHedging(numHedges > 1) {} std::shared_ptr makeRequest(RequestManager* mgr) { auto req = std::make_shared(mgr, cmdState.lock()); @@ -248,6 +249,7 @@ private: AtomicWord requestCnt{0}; // blocks sending requests bool isLocked{false}; + bool isHedging{false}; Mutex mutex = MONGO_MAKE_LATCH("NetworkInterfaceTL::RequestManager::mutex"); }; -- cgit v1.2.1