diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2020-11-02 20:04:42 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-09 01:02:09 +0000 |
commit | 7925d3e9a759e983a49cf44b90d58f77fbf7fb95 (patch) | |
tree | 1f6b717fd9756ea4fe17aca74d445cd12e91d46f /src/mongo/transport | |
parent | 37df7f2350b8cbe943fc075a68b41b8eb31d012e (diff) | |
download | mongo-7925d3e9a759e983a49cf44b90d58f77fbf7fb95.tar.gz |
SERVER-49108 Convert buildInfo command to async implementation
Diffstat (limited to 'src/mongo/transport')
-rw-r--r-- | src/mongo/transport/service_state_machine.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp index ef278c1ba88..103dcf3fdcf 100644 --- a/src/mongo/transport/service_state_machine.cpp +++ b/src/mongo/transport/service_state_machine.cpp @@ -304,10 +304,6 @@ private: boost::optional<MessageCompressorId> _compressorId; Message _inMessage; Message _outMessage; - - // Allows delegating destruction of opCtx to another function to potentially remove its cost - // from the critical path. This is currently only used in `processMessage()`. - ServiceContext::UniqueOperationContext _killedOpCtx; }; Future<void> ServiceStateMachine::Impl::sourceMessage() { @@ -456,13 +452,14 @@ Future<void> ServiceStateMachine::Impl::processMessage() { .then([this, &compressorMgr = compressorMgr, opCtx = std::move(opCtx)]( DbResponse dbresponse) mutable -> void { // opCtx must be killed and delisted here so that the operation cannot show up in - // currentOp results after the response reaches the client. The destruction is postponed - // for later to mitigate its performance impact on the critical path of execution. + // currentOp results after the response reaches the client. Destruction of the already + // killed opCtx is postponed for later (i.e., after completion of the future-chain) to + // mitigate its performance impact on the critical path of execution. + // Note that destroying futures after execution, rather that postponing the destruction + // until completion of the future-chain, would expose the cost of destroying opCtx to + // the critical path and result in serious performance implications. _serviceContext->killAndDelistOperation(opCtx.get(), ErrorCodes::OperationIsKilledAndDelisted); - invariant(!_killedOpCtx); - _killedOpCtx = std::move(opCtx); - // Format our response, if we have one Message& toSink = dbresponse.response; if (!toSink.empty()) { @@ -551,11 +548,6 @@ void ServiceStateMachine::Impl::runOnce() { return sinkMessage(); }) .getAsync([this](Status status) { - // Destroy the opCtx (already killed) here, to potentially use the delay between - // clients' requests to hide the destruction cost. - if (MONGO_likely(_killedOpCtx)) { - _killedOpCtx.reset(); - } if (!status.isOK()) { _state.store(State::EndSession); // The service executor failed to schedule the task. This could for example be that @@ -659,12 +651,6 @@ void ServiceStateMachine::Impl::setCleanupHook(std::function<void()> hook) { void ServiceStateMachine::Impl::cleanupSession(const Status& status) { LOGV2_INFO(5127900, "Ending session", "error"_attr = status); - // Ensure the delayed destruction of opCtx always happens before doing the cleanup. - if (MONGO_likely(_killedOpCtx)) { - _killedOpCtx.reset(); - } - invariant(!_killedOpCtx); - cleanupExhaustResources(); { |