summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Freed <patrick.freed@mongodb.com>2023-02-14 18:27:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-15 00:30:58 +0000
commitff7fcd42e84317e2a34e0b413ee4cc1d9be66884 (patch)
tree3d328358d82419b805c1682ff6cbd3cdc7437732
parent9b7a803ba98afab6b101c32fe44f9043c170b1b5 (diff)
downloadmongo-ff7fcd42e84317e2a34e0b413ee4cc1d9be66884.tar.gz
SERVER-73307 Ensure CurOpStack always has access to its OperationContext (#10536)
This also ensures base lock stats are properly subtracted out when getting the lock stats for a given sub operation (fixes SERVER-73571).
-rw-r--r--src/mongo/db/catalog/drop_database.cpp2
-rw-r--r--src/mongo/db/commands/count_cmd.cpp2
-rw-r--r--src/mongo/db/commands/dbcommands.cpp6
-rw-r--r--src/mongo/db/commands/distinct.cpp2
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp12
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp2
-rw-r--r--src/mongo/db/concurrency/lock_state_test.cpp47
-rw-r--r--src/mongo/db/curop.cpp116
-rw-r--r--src/mongo/db/curop.h66
-rw-r--r--src/mongo/db/curop_test.cpp7
-rw-r--r--src/mongo/db/db_raii.cpp6
-rw-r--r--src/mongo/db/db_raii_test.cpp2
-rw-r--r--src/mongo/db/dbdirectclient.cpp3
-rw-r--r--src/mongo/db/error_labels_test.cpp2
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp4
-rw-r--r--src/mongo/db/index_builds_coordinator_mongod.cpp3
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp26
-rw-r--r--src/mongo/db/pipeline/document_source_merge_cursors_test.cpp2
-rw-r--r--src/mongo/db/query/find.cpp2
-rw-r--r--src/mongo/db/repl/oplog_applier_utils.cpp3
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp2
-rw-r--r--src/mongo/db/s/config/initial_split_policy.cpp2
-rw-r--r--src/mongo/db/s/global_index/global_index_cloner_fetcher.cpp2
-rw-r--r--src/mongo/db/s/periodic_sharded_index_consistency_checker.cpp2
-rw-r--r--src/mongo/db/s/resharding/resharding_collection_cloner.cpp2
-rw-r--r--src/mongo/db/s/resharding/resharding_data_copy_util.cpp2
-rw-r--r--src/mongo/db/s/resharding/resharding_txn_cloner.cpp2
-rw-r--r--src/mongo/db/service_entry_point_common.cpp5
-rw-r--r--src/mongo/s/commands/strategy.cpp2
-rw-r--r--src/mongo/s/query/results_merger_test_fixture.cpp2
-rw-r--r--src/mongo/s/service_entry_point_mongos.cpp3
31 files changed, 192 insertions, 149 deletions
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp
index bd5d3ac873a..6f1ec6be549 100644
--- a/src/mongo/db/catalog/drop_database.cpp
+++ b/src/mongo/db/catalog/drop_database.cpp
@@ -139,7 +139,7 @@ Status _dropDatabase(OperationContext* opCtx, const DatabaseName& dbName, bool a
dbName != NamespaceString::kAdminDb);
{
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->setNS_inlock(dbName);
}
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index 1634d98adc2..53f473a3137 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -329,7 +329,7 @@ public:
}
curOp->debug().setPlanSummaryMetrics(summaryStats);
- if (curOp->shouldDBProfile(opCtx)) {
+ if (curOp->shouldDBProfile()) {
auto&& explainer = exec->getPlanExplainer();
auto&& [stats, _] =
explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index efca6b757d7..83a886f42c3 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -634,7 +634,7 @@ public:
NamespaceString::DollarInDbNameBehavior::Allow));
{
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->setNS_inlock(dbname);
}
@@ -676,9 +676,7 @@ public:
{
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->enter_inlock(
- opCtx,
- dbname,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(dbname));
+ dbname, CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(dbname));
}
db->getStats(opCtx, &reply, cmd.getFreeStorage(), cmd.getScale());
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 4a839da1aad..203a17e9e93 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -359,7 +359,7 @@ public:
}
curOp->debug().setPlanSummaryMetrics(stats);
- if (curOp->shouldDBProfile(opCtx)) {
+ if (curOp->shouldDBProfile()) {
auto&& [stats, _] =
explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
curOp->debug().execStats = std::move(stats);
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 4e9c4a6f3c7..044f8571485 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -369,9 +369,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
{
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->enter_inlock(
- opCtx,
- nsString,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.dbName()));
+ nsString, CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.dbName()));
}
assertCanWrite_inlock(opCtx, nsString);
@@ -402,7 +400,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
// Fill out OpDebug with the number of deleted docs.
opDebug->additiveMetrics.ndeleted = docFound ? 1 : 0;
- if (curOp->shouldDBProfile(opCtx)) {
+ if (curOp->shouldDBProfile()) {
auto&& explainer = exec->getPlanExplainer();
auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
curOp->debug().execStats = std::move(stats);
@@ -435,9 +433,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
{
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->enter_inlock(
- opCtx,
- nsString,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.dbName()));
+ nsString, CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.dbName()));
}
assertCanWrite_inlock(opCtx, nsString);
@@ -506,7 +502,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
dotsAndDollarsFieldsCounters.incrementForUpsert(!updateResult.upsertedId.isEmpty());
}
- if (curOp->shouldDBProfile(opCtx)) {
+ if (curOp->shouldDBProfile()) {
auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
curOp->debug().execStats = std::move(stats);
}
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index 7b5931d8c0e..66e570b3eda 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -661,7 +661,7 @@ public:
// generate the stats eagerly for all operations due to cost.
if (cursorPin->getExecutor()->lockPolicy() !=
PlanExecutor::LockPolicy::kLocksInternally &&
- curOp->shouldDBProfile(opCtx)) {
+ curOp->shouldDBProfile()) {
auto&& explainer = exec->getPlanExplainer();
auto&& [stats, _] =
explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
diff --git a/src/mongo/db/concurrency/lock_state_test.cpp b/src/mongo/db/concurrency/lock_state_test.cpp
index d0475730565..1293e230f69 100644
--- a/src/mongo/db/concurrency/lock_state_test.cpp
+++ b/src/mongo/db/concurrency/lock_state_test.cpp
@@ -37,6 +37,7 @@
#include "mongo/config.h"
#include "mongo/db/concurrency/lock_manager_test_help.h"
#include "mongo/db/concurrency/locker.h"
+#include "mongo/db/curop.h"
#include "mongo/db/service_context_test_fixture.h"
#include "mongo/transport/session.h"
#include "mongo/transport/transport_layer_mock.h"
@@ -1123,6 +1124,52 @@ TEST_F(LockerImplTest, GetLockerInfoShouldReportPendingLocks) {
ASSERT(conflictingLocker.unlockGlobal());
}
+TEST_F(LockerImplTest, GetLockerInfoShouldSubtractBase) {
+ auto opCtx = makeOperationContext();
+ auto locker = opCtx->lockState();
+ const ResourceId dbId(RESOURCE_DATABASE, DatabaseName(boost::none, "SubtractTestDB"));
+
+ auto numAcquisitions = [&](boost::optional<SingleThreadedLockStats> baseStats) {
+ Locker::LockerInfo info;
+ locker->getLockerInfo(&info, baseStats);
+ return info.stats.get(dbId, MODE_IX).numAcquisitions;
+ };
+ auto getBaseStats = [&] {
+ return CurOp::get(opCtx.get())->getLockStatsBase();
+ };
+
+ locker->lockGlobal(opCtx.get(), MODE_IX);
+
+ // Obtain a lock before any other ops have been pushed to the stack.
+ locker->lock(dbId, MODE_IX);
+ locker->unlock(dbId);
+
+ ASSERT_EQUALS(numAcquisitions(getBaseStats()), 1) << "The acquisition should be reported";
+
+ // Push another op to the stack and obtain a lock.
+ CurOp superOp;
+ superOp.push(opCtx.get());
+ locker->lock(dbId, MODE_IX);
+ locker->unlock(dbId);
+
+ ASSERT_EQUALS(numAcquisitions(getBaseStats()), 1)
+ << "Only superOp's acquisition should be reported";
+
+ // Then push another op to the stack and obtain another lock.
+ CurOp subOp;
+ subOp.push(opCtx.get());
+ locker->lock(dbId, MODE_IX);
+ locker->unlock(dbId);
+
+ ASSERT_EQUALS(numAcquisitions(getBaseStats()), 1)
+ << "Only the latest acquisition should be reported";
+
+ ASSERT_EQUALS(numAcquisitions({}), 3)
+ << "All acquisitions should be reported when no base is subtracted out.";
+
+ ASSERT(locker->unlockGlobal());
+}
+
TEST_F(LockerImplTest, ReaquireLockPendingUnlock) {
auto opCtx = makeOperationContext();
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 01c358369f8..bc4e9e3176b 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -94,7 +94,9 @@ class CurOp::CurOpStack {
CurOpStack& operator=(const CurOpStack&) = delete;
public:
- CurOpStack() : _base(nullptr, this) {}
+ CurOpStack() {
+ _pushNoLock(&_base);
+ }
/**
* Returns the top of the CurOp stack.
@@ -104,23 +106,14 @@ public:
}
/**
- * Adds "curOp" to the top of the CurOp stack for a client. Called by CurOp's constructor.
+ * Adds "curOp" to the top of the CurOp stack for a client.
+ *
+ * This sets the "_parent", "_stack", and "_lockStatsBase" fields
+ * of "curOp".
*/
- void push(OperationContext* opCtx, CurOp* curOp) {
- invariant(opCtx);
- if (_opCtx) {
- invariant(_opCtx == opCtx);
- } else {
- _opCtx = opCtx;
- }
- stdx::lock_guard<Client> lk(*_opCtx->getClient());
- push_nolock(curOp);
- }
-
- void push_nolock(CurOp* curOp) {
- invariant(!curOp->_parent);
- curOp->_parent = _top;
- _top = curOp;
+ void push(CurOp* curOp) {
+ stdx::lock_guard<Client> lk(*opCtx()->getClient());
+ _pushNoLock(curOp);
}
/**
@@ -137,31 +130,52 @@ public:
// the client during the final pop.
const bool shouldLock = _top->_parent;
if (shouldLock) {
- invariant(_opCtx);
- _opCtx->getClient()->lock();
+ opCtx()->getClient()->lock();
}
invariant(_top);
CurOp* retval = _top;
_top = _top->_parent;
if (shouldLock) {
- _opCtx->getClient()->unlock();
+ opCtx()->getClient()->unlock();
}
return retval;
}
+ OperationContext* opCtx() {
+ auto ctx = _curopStack.owner(this);
+ invariant(ctx);
+ return ctx;
+ }
+
private:
- OperationContext* _opCtx = nullptr;
+ void _pushNoLock(CurOp* curOp) {
+ invariant(!curOp->_parent);
+ curOp->_stack = this;
+ curOp->_parent = _top;
+
+ // If `curOp` is a sub-operation, we store the snapshot of lock stats as the base lock stats
+ // of the current operation.
+ if (_top) {
+ curOp->_lockStatsBase = opCtx()->lockState()->getLockerInfo(boost::none)->stats;
+ }
+
+ _top = curOp;
+ }
// Top of the stack of CurOps for a Client.
CurOp* _top = nullptr;
// The bottom-most CurOp for a client.
- const CurOp _base;
+ CurOp _base;
};
const OperationContext::Decoration<CurOp::CurOpStack> CurOp::_curopStack =
OperationContext::declareDecoration<CurOp::CurOpStack>();
+void CurOp::push(OperationContext* opCtx) {
+ _curopStack(opCtx).push(this);
+}
+
CurOp* CurOp::get(const OperationContext* opCtx) {
return get(*opCtx);
}
@@ -248,7 +262,7 @@ void CurOp::reportCurrentOpForClient(OperationContext* opCtx,
lsid->serialize(&lsidBuilder);
}
- CurOp::get(clientOpCtx)->reportState(clientOpCtx, infoBuilder, truncateOps);
+ CurOp::get(clientOpCtx)->reportState(infoBuilder, truncateOps);
}
#ifndef MONGO_CONFIG_USE_RAW_LATCHES
@@ -282,6 +296,11 @@ bool CurOp::currentOpBelongsToTenant(Client* client, TenantId tenantId) {
return true;
}
+OperationContext* CurOp::opCtx() {
+ invariant(_stack);
+ return _stack->opCtx();
+}
+
void CurOp::setOpDescription_inlock(const BSONObj& opDescription) {
_opDescription = serializeDollarDbInOpDescription(_nss.tenantId(), opDescription);
}
@@ -290,39 +309,13 @@ void CurOp::setGenericCursor_inlock(GenericCursor gc) {
_genericCursor = std::move(gc);
}
-void CurOp::_finishInit(OperationContext* opCtx, CurOpStack* stack) {
- _stack = stack;
- _tickSource = globalSystemTickSource();
-
- if (opCtx) {
- _stack->push(opCtx, this);
- } else {
- _stack->push_nolock(this);
- }
-}
-
-CurOp::CurOp(OperationContext* opCtx) {
- // If this is a sub-operation, we store the snapshot of lock stats as the base lock stats of the
- // current operation.
- if (_parent != nullptr)
- _lockStatsBase = opCtx->lockState()->getLockerInfo(boost::none)->stats;
-
- // Add the CurOp object onto the stack of active CurOp objects.
- _finishInit(opCtx, &_curopStack(opCtx));
-}
-
-CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) {
- _finishInit(opCtx, stack);
-}
-
CurOp::~CurOp() {
if (parent() != nullptr)
parent()->yielded(_numYields.load());
- invariant(this == _stack->pop());
+ invariant(!_stack || this == _stack->pop());
}
-void CurOp::setGenericOpRequestDetails(OperationContext* opCtx,
- NamespaceString nss,
+void CurOp::setGenericOpRequestDetails(NamespaceString nss,
const Command* command,
BSONObj cmdObj,
NetworkOp op) {
@@ -332,7 +325,7 @@ void CurOp::setGenericOpRequestDetails(OperationContext* opCtx,
const bool isCommand = (op == dbMsg || (op == dbQuery && nss.isCommand()));
auto logicalOp = (command ? command->getLogicalOp() : networkOpToLogicalOp(op));
- stdx::lock_guard<Client> clientLock(*opCtx->getClient());
+ stdx::lock_guard<Client> clientLock(*opCtx()->getClient());
_isCommand = _debug.iscommand = isCommand;
_logicalOp = _debug.logicalOp = logicalOp;
_networkOp = _debug.networkOp = op;
@@ -370,14 +363,14 @@ void CurOp::setNS_inlock(const DatabaseName& dbName) {
_nss = NamespaceString(dbName);
}
-TickSource::Tick CurOp::startTime(OperationContext* opCtx) {
+TickSource::Tick CurOp::startTime() {
auto start = _start.load();
if (start != 0) {
return start;
}
// Start the CPU timer if this system supports it.
- if (auto cpuTimers = OperationCPUTimers::get(opCtx)) {
+ if (auto cpuTimers = OperationCPUTimers::get(opCtx())) {
_cpuTimer = cpuTimers->makeTimer();
_cpuTimer->start();
}
@@ -411,14 +404,14 @@ Microseconds CurOp::computeElapsedTimeTotal(TickSource::Tick startTime,
return _tickSource->ticksTo<Microseconds>(endTime - startTime);
}
-void CurOp::enter_inlock(OperationContext* opCtx, NamespaceString nss, int dbProfileLevel) {
- ensureStarted(opCtx);
+void CurOp::enter_inlock(NamespaceString nss, int dbProfileLevel) {
+ ensureStarted();
_nss = std::move(nss);
raiseDbProfileLevel(dbProfileLevel);
}
-void CurOp::enter_inlock(OperationContext* opCtx, const DatabaseName& dbName, int dbProfileLevel) {
- enter_inlock(opCtx, NamespaceString(dbName), dbProfileLevel);
+void CurOp::enter_inlock(const DatabaseName& dbName, int dbProfileLevel) {
+ enter_inlock(NamespaceString(dbName), dbProfileLevel);
}
void CurOp::raiseDbProfileLevel(int dbProfileLevel) {
@@ -427,12 +420,12 @@ void CurOp::raiseDbProfileLevel(int dbProfileLevel) {
static constexpr size_t appendMaxElementSize = 50 * 1024;
-bool CurOp::completeAndLogOperation(OperationContext* opCtx,
- logv2::LogComponent component,
+bool CurOp::completeAndLogOperation(logv2::LogComponent component,
std::shared_ptr<const ProfileFilter> filter,
boost::optional<size_t> responseLength,
boost::optional<long long> slowMsOverride,
bool forceLog) {
+ auto opCtx = this->opCtx();
const long long slowMs = slowMsOverride.value_or(serverGlobalParams.slowMS.load());
// Record the size of the response returned to the client, if applicable.
@@ -668,7 +661,8 @@ BSONObj CurOp::truncateAndSerializeGenericCursor(GenericCursor* cursor,
return serialized;
}
-void CurOp::reportState(OperationContext* opCtx, BSONObjBuilder* builder, bool truncateOps) {
+void CurOp::reportState(BSONObjBuilder* builder, bool truncateOps) {
+ auto opCtx = this->opCtx();
auto start = _start.load();
if (start) {
auto end = _end.load();
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index a0cd46a4e0e..98cbaf8087e 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -30,7 +30,6 @@
#pragma once
-#include "mongo/util/duration.h"
#include <memory>
#include "mongo/config.h"
@@ -48,7 +47,9 @@
#include "mongo/logv2/attribute_storage.h"
#include "mongo/logv2/log_component.h"
#include "mongo/platform/atomic_word.h"
+#include "mongo/util/duration.h"
#include "mongo/util/progress_meter.h"
+#include "mongo/util/system_tick_source.h"
#include "mongo/util/tick_source.h"
#include "mongo/util/time_support.h"
@@ -408,9 +409,19 @@ public:
boost::optional<size_t> maxQuerySize);
/**
- * Constructs a nested CurOp at the top of the given "opCtx"'s CurOp stack.
+ * Pushes this CurOp to the top of the given "opCtx"'s CurOp stack.
+ */
+ void push(OperationContext* opCtx);
+
+ CurOp() = default;
+
+ /**
+ * This allows the caller to set the command on the CurOp without using setCommand_inlock and
+ * having to acquire the Client lock or having to leave a comment indicating why the
+ * client lock isn't necessary.
*/
- explicit CurOp(OperationContext* opCtx);
+ explicit CurOp(const Command* command) : _command{command} {}
+
~CurOp();
/**
@@ -419,8 +430,7 @@ public:
* is set early in the request processing backend and does not typically need to be called
* thereafter. Locks the client as needed to apply the specified settings.
*/
- void setGenericOpRequestDetails(OperationContext* opCtx,
- NamespaceString nss,
+ void setGenericOpRequestDetails(NamespaceString nss,
const Command* command,
BSONObj cmdObj,
NetworkOp op);
@@ -431,8 +441,7 @@ public:
* to file under the given LogComponent. Returns 'true' if, in addition to being logged, this
* operation should also be profiled.
*/
- bool completeAndLogOperation(OperationContext* opCtx,
- logv2::LogComponent logComponent,
+ bool completeAndLogOperation(logv2::LogComponent logComponent,
std::shared_ptr<const ProfileFilter> filter,
boost::optional<size_t> responseLength = boost::none,
boost::optional<long long> slowMsOverride = boost::none,
@@ -458,8 +467,8 @@ public:
return _originatingCommand;
}
- void enter_inlock(OperationContext* opCtx, NamespaceString nss, int dbProfileLevel);
- void enter_inlock(OperationContext* opCtx, const DatabaseName& dbName, int dbProfileLevel);
+ void enter_inlock(NamespaceString nss, int dbProfileLevel);
+ void enter_inlock(const DatabaseName& dbName, int dbProfileLevel);
/**
* Sets the type of the current network operation.
@@ -526,7 +535,7 @@ public:
*
* When a custom filter is set, we conservatively assume it would match this operation.
*/
- bool shouldDBProfile(OperationContext* opCtx) {
+ bool shouldDBProfile() {
// Profile level 2 should override any sample rate or slowms settings.
if (_dbprofile >= 2)
return true;
@@ -534,7 +543,7 @@ public:
if (_dbprofile <= 0)
return false;
- if (CollectionCatalog::get(opCtx)->getDatabaseProfileSettings(getNSS().db()).filter)
+ if (CollectionCatalog::get(opCtx())->getDatabaseProfileSettings(getNSS().db()).filter)
return true;
return elapsedTimeExcludingPauses() >= Milliseconds{serverGlobalParams.slowMS.load()};
@@ -580,8 +589,8 @@ public:
// negative, if the system time has been reset during the course of this operation.
//
- void ensureStarted(OperationContext* opCtx) {
- static_cast<void>(startTime(opCtx));
+ void ensureStarted() {
+ (void)startTime();
}
bool isStarted() const {
return _start.load() != 0;
@@ -784,7 +793,7 @@ public:
* If called from a thread other than the one executing the operation associated with this
* CurOp, it is necessary to lock the associated Client object before executing this method.
*/
- void reportState(OperationContext* opCtx, BSONObjBuilder* builder, bool truncateOps = false);
+ void reportState(BSONObjBuilder* builder, bool truncateOps = false);
/**
* Sets the message for FailPoints used.
@@ -886,14 +895,15 @@ public:
private:
class CurOpStack;
- TickSource::Tick startTime(OperationContext* opCtx);
- Microseconds computeElapsedTimeTotal(TickSource::Tick startTime,
- TickSource::Tick endTime) const;
-
/**
- * Adds 'this' to the stack of active CurOp objects.
+ * Gets the OperationContext associated with this CurOp.
+ * This must only be called after the CurOp has been pushed to an OperationContext's CurOpStack.
*/
- void _finishInit(OperationContext* opCtx, CurOpStack* stack);
+ OperationContext* opCtx();
+
+ TickSource::Tick startTime();
+ Microseconds computeElapsedTimeTotal(TickSource::Tick startTime,
+ TickSource::Tick endTime) const;
/**
* Handles failpoints that check whether a command has completed or not.
@@ -903,10 +913,14 @@ private:
static const OperationContext::Decoration<CurOpStack> _curopStack;
- CurOp(OperationContext*, CurOpStack*);
+ // The stack containing this CurOp instance.
+ // This is set when this instance is pushed to the stack.
+ CurOpStack* _stack{nullptr};
- CurOpStack* _stack;
+ // The CurOp beneath this CurOp instance in its stack, if any.
+ // This is set when this instance is pushed to a non-empty stack.
CurOp* _parent{nullptr};
+
const Command* _command{nullptr};
// The time at which this CurOp instance was marked as started.
@@ -951,12 +965,14 @@ private:
boost::optional<GenericCursor> _genericCursor;
std::string _planSummary;
- boost::optional<SingleThreadedLockStats>
- _lockStatsBase; // This is the snapshot of lock stats taken when curOp is constructed.
+
+ // The snapshot of lock stats taken when this CurOp instance is pushed to a
+ // CurOpStack.
+ boost::optional<SingleThreadedLockStats> _lockStatsBase;
UserAcquisitionStats _userAcquisitionStats;
- TickSource* _tickSource = nullptr;
+ TickSource* _tickSource = globalSystemTickSource();
// These values are used to calculate the amount of time spent planning a query.
std::atomic<TickSource::Tick> _queryPlanningStart{0}; // NOLINT
std::atomic<TickSource::Tick> _queryPlanningEnd{0}; // NOLINT
diff --git a/src/mongo/db/curop_test.cpp b/src/mongo/db/curop_test.cpp
index d944a29f1de..b27272082ab 100644
--- a/src/mongo/db/curop_test.cpp
+++ b/src/mongo/db/curop_test.cpp
@@ -206,8 +206,7 @@ TEST(CurOpTest, OptionalAdditiveMetricsNotDisplayedIfUninitialized) {
BSONObj command = BSON("a" << 3);
// Set dummy 'ns' and 'command'.
- curop->setGenericOpRequestDetails(opCtx.get(),
- NamespaceString::createNamespaceString_forTest("myDb.coll"),
+ curop->setGenericOpRequestDetails(NamespaceString::createNamespaceString_forTest("myDb.coll"),
nullptr,
command,
NetworkOp::dbQuery);
@@ -235,7 +234,7 @@ TEST(CurOpTest, ShouldNotReportFailpointMsgIfNotSet) {
BSONObjBuilder reportedStateWithoutFailpointMsg;
{
stdx::lock_guard<Client> lk(*opCtx->getClient());
- curop->reportState(opCtx.get(), &reportedStateWithoutFailpointMsg);
+ curop->reportState(&reportedStateWithoutFailpointMsg);
}
auto bsonObj = reportedStateWithoutFailpointMsg.done();
@@ -257,7 +256,7 @@ TEST(CurOpTest, ElapsedTimeReflectsTickSource) {
ASSERT_FALSE(curop->isStarted());
- curop->ensureStarted(opCtx.get());
+ curop->ensureStarted();
ASSERT_TRUE(curop->isStarted());
tickSourceMock->advance(Milliseconds{20});
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index e4259bb33a3..1617a7faae3 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -486,7 +486,7 @@ AutoStatsTracker::AutoStatsTracker(
}
stdx::lock_guard<Client> clientLock(*_opCtx->getClient());
- CurOp::get(_opCtx)->enter_inlock(opCtx, nss, dbProfilingLevel);
+ CurOp::get(_opCtx)->enter_inlock(nss, dbProfilingLevel);
}
AutoStatsTracker::~AutoStatsTracker() {
@@ -1513,8 +1513,8 @@ OldClientContext::OldClientContext(OperationContext* opCtx,
}
stdx::lock_guard<Client> lk(*_opCtx->getClient());
- currentOp->enter_inlock(
- opCtx, nss, CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(_db->name()));
+ currentOp->enter_inlock(nss,
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(_db->name()));
}
AutoGetCollectionForReadCommandMaybeLockFree::AutoGetCollectionForReadCommandMaybeLockFree(
diff --git a/src/mongo/db/db_raii_test.cpp b/src/mongo/db/db_raii_test.cpp
index 6f3bb7efcea..ce6099b6b68 100644
--- a/src/mongo/db/db_raii_test.cpp
+++ b/src/mongo/db/db_raii_test.cpp
@@ -74,7 +74,7 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> makeTailableQueryPlan(
awaitDataState(opCtx).shouldWaitForInserts = true;
awaitDataState(opCtx).waitForInsertsDeadline =
opCtx->getServiceContext()->getPreciseClockSource()->now() + Seconds(1);
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
const boost::intrusive_ptr<ExpressionContext> expCtx;
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 571a10f263e..14d047850af 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -125,7 +125,8 @@ namespace {
DbResponse loopbackBuildResponse(OperationContext* const opCtx, Message& toSend) {
DirectClientScope directClientScope(opCtx);
- CurOp curOp(opCtx);
+ CurOp curOp;
+ curOp.push(opCtx);
toSend.header().setId(nextMessageId());
toSend.header().setResponseToMsgId(0);
diff --git a/src/mongo/db/error_labels_test.cpp b/src/mongo/db/error_labels_test.cpp
index f0920b0085f..e7db1adb6ba 100644
--- a/src/mongo/db/error_labels_test.cpp
+++ b/src/mongo/db/error_labels_test.cpp
@@ -126,7 +126,7 @@ public:
void setCommand(BSONObj cmdObj) const {
CurOp::get(opCtx())->setGenericOpRequestDetails(
- opCtx(), _testNss, nullptr, cmdObj, NetworkOp::dbMsg);
+ _testNss, nullptr, cmdObj, NetworkOp::dbMsg);
}
void setGetMore(BSONObj originatingCommand) const {
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index b145d63b15f..9f4092b7ba6 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -356,7 +356,7 @@ void updateCurOpForCommitOrAbort(OperationContext* opCtx, StringData fieldName,
auto opDescObj = builder.obj();
curOp->setLogicalOp_inlock(LogicalOp::opCommand);
curOp->setOpDescription_inlock(opDescObj);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
}
/**
@@ -1921,7 +1921,7 @@ void IndexBuildsCoordinator::updateCurOpOpDescription(OperationContext* opCtx,
curOp->setLogicalOp_inlock(LogicalOp::opCommand);
curOp->setOpDescription_inlock(opDescObj);
curOp->setNS_inlock(nss);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
}
Status IndexBuildsCoordinator::_setUpIndexBuildForTwoPhaseRecovery(
diff --git a/src/mongo/db/index_builds_coordinator_mongod.cpp b/src/mongo/db/index_builds_coordinator_mongod.cpp
index 327606c75e2..f8062f844d1 100644
--- a/src/mongo/db/index_builds_coordinator_mongod.cpp
+++ b/src/mongo/db/index_builds_coordinator_mongod.cpp
@@ -423,8 +423,7 @@ IndexBuildsCoordinatorMongod::_startIndexBuild(OperationContext* opCtx,
// Logs the index build statistics if it took longer than the server parameter `slowMs`
// to complete.
CurOp::get(opCtx.get())
- ->completeAndLogOperation(opCtx.get(),
- MONGO_LOGV2_DEFAULT_COMPONENT,
+ ->completeAndLogOperation(MONGO_LOGV2_DEFAULT_COMPONENT,
CollectionCatalog::get(opCtx.get())
->getDatabaseProfileSettings(nss.dbName())
.filter);
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index 66138d08c6e..bd9463bb1af 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -243,7 +243,6 @@ void finishCurOp(OperationContext* opCtx, CurOp* curOp) {
// Mark the op as complete, and log it if appropriate. Returns a boolean indicating whether
// this op should be sampled for profiling.
const bool shouldProfile = curOp->completeAndLogOperation(
- opCtx,
MONGO_LOGV2_DEFAULT_COMPONENT,
CollectionCatalog::get(opCtx)
->getDatabaseProfileSettings(curOp->getNSS().dbName())
@@ -743,7 +742,7 @@ WriteResult performInserts(OperationContext* opCtx,
stdx::lock_guard<Client> lk(*opCtx->getClient());
curOp.setNS_inlock(wholeOp.getNamespace());
curOp.setLogicalOp_inlock(LogicalOp::opInsert);
- curOp.ensureStarted(opCtx);
+ curOp.ensureStarted();
curOp.debug().additiveMetrics.ninserted = 0;
}
@@ -995,7 +994,7 @@ static SingleWriteResult performSingleUpdateOp(OperationContext* opCtx,
CollectionQueryInfo::get(coll).notifyOfQuery(opCtx, coll, summary);
}
- if (curOp.shouldDBProfile(opCtx)) {
+ if (curOp.shouldDBProfile()) {
auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
curOp.debug().execStats = std::move(stats);
}
@@ -1046,7 +1045,7 @@ static SingleWriteResult performSingleUpdateOpWithDupKeyRetry(
curOp.setNetworkOp_inlock(dbUpdate);
curOp.setLogicalOp_inlock(LogicalOp::opUpdate);
curOp.setOpDescription_inlock(op.toBSON());
- curOp.ensureStarted(opCtx);
+ curOp.ensureStarted();
}
uassert(ErrorCodes::InvalidOptions,
@@ -1173,10 +1172,8 @@ WriteResult performUpdates(OperationContext* opCtx,
const Command* cmd = parentCurOp.getCommand();
boost::optional<CurOp> curOp;
if (source != OperationSource::kTimeseriesInsert) {
- curOp.emplace(opCtx);
-
- stdx::lock_guard<Client> lk(*opCtx->getClient());
- curOp->setCommand_inlock(cmd);
+ curOp.emplace(cmd);
+ curOp->push(opCtx);
}
ON_BLOCK_EXIT([&] {
if (curOp) {
@@ -1271,7 +1268,7 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx,
curOp.setNetworkOp_inlock(dbDelete);
curOp.setLogicalOp_inlock(LogicalOp::opDelete);
curOp.setOpDescription_inlock(op.toBSON());
- curOp.ensureStarted(opCtx);
+ curOp.ensureStarted();
}
auto request = DeleteRequest{};
@@ -1372,7 +1369,7 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx,
}
curOp.debug().setPlanSummaryMetrics(summary);
- if (curOp.shouldDBProfile(opCtx)) {
+ if (curOp.shouldDBProfile()) {
auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
curOp.debug().execStats = std::move(stats);
}
@@ -1436,11 +1433,8 @@ WriteResult performDeletes(OperationContext* opCtx,
// Add Command pointer to the nested CurOp.
auto& parentCurOp = *CurOp::get(opCtx);
const Command* cmd = parentCurOp.getCommand();
- CurOp curOp(opCtx);
- {
- stdx::lock_guard<Client> lk(*opCtx->getClient());
- curOp.setCommand_inlock(cmd);
- }
+ CurOp curOp(cmd);
+ curOp.push(opCtx);
ON_BLOCK_EXIT([&] {
if (MONGO_unlikely(hangBeforeChildRemoveOpFinishes.shouldFail())) {
CurOpFailpointHelpers::waitWhileFailPointEnabled(
@@ -2816,7 +2810,7 @@ write_ops::InsertCommandReply performTimeseriesWrites(
stdx::lock_guard<Client> lk(*opCtx->getClient());
curOp.setNS_inlock(ns(request));
curOp.setLogicalOp_inlock(LogicalOp::opInsert);
- curOp.ensureStarted(opCtx);
+ curOp.ensureStarted();
curOp.debug().additiveMetrics.ninserted = 0;
}
diff --git a/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp b/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
index e652aba8588..b0c6fff8037 100644
--- a/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
+++ b/src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
@@ -115,7 +115,7 @@ public:
setupShards(shards);
- CurOp::get(operationContext())->ensureStarted(operationContext());
+ CurOp::get(operationContext())->ensureStarted();
}
boost::intrusive_ptr<ExpressionContext> getExpCtx() {
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index 049eb3b63a7..cc11e424c18 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -125,7 +125,7 @@ void endQueryOp(OperationContext* opCtx,
CollectionQueryInfo::get(collection).notifyOfQuery(opCtx, collection, summaryStats);
}
- if (curOp->shouldDBProfile(opCtx)) {
+ if (curOp->shouldDBProfile()) {
auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
curOp->debug().execStats = std::move(stats);
}
diff --git a/src/mongo/db/repl/oplog_applier_utils.cpp b/src/mongo/db/repl/oplog_applier_utils.cpp
index 9a7fddb9503..8e4661245a2 100644
--- a/src/mongo/db/repl/oplog_applier_utils.cpp
+++ b/src/mongo/db/repl/oplog_applier_utils.cpp
@@ -320,7 +320,8 @@ Status OplogApplierUtils::applyOplogEntryOrGroupedInsertsCommon(
auto op = entryOrGroupedInserts.getOp();
// Count each log op application as a separate operation, for reporting purposes
- CurOp individualOp(opCtx);
+ CurOp individualOp;
+ individualOp.push(opCtx);
const NamespaceString nss(op.getNss());
auto opType = op.getOpType();
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 2366d8f61d5..e82a78da920 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -4239,7 +4239,7 @@ void ReplicationCoordinatorImpl::_reconfigToRemoveNewlyAddedField(
curOp->setOpDescription_inlock(bob.obj());
// TODO SERVER-62491 Use systemTenantId.
curOp->setNS_inlock(NamespaceString(boost::none, "local.system.replset"));
- curOp->ensureStarted(opCtx.get());
+ curOp->ensureStarted();
}
if (MONGO_unlikely(hangDuringAutomaticReconfig.shouldFail())) {
diff --git a/src/mongo/db/s/config/initial_split_policy.cpp b/src/mongo/db/s/config/initial_split_policy.cpp
index 3e469b189c8..9acef88b380 100644
--- a/src/mongo/db/s/config/initial_split_policy.cpp
+++ b/src/mongo/db/s/config/initial_split_policy.cpp
@@ -705,7 +705,7 @@ BSONObjSet SamplingBasedSplitPolicy::createFirstSplitPoints(OperationContext* op
// The BlockingResultsMerger underlying the $mergeCursors stage records how long was
// spent waiting for samples from the donor shards. It doing so requires the CurOp
// to be marked as having started.
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
_appendSplitPointsFromSample(
&splitPoints, shardKey, _numInitialChunks - splitPoints.size() - 1);
diff --git a/src/mongo/db/s/global_index/global_index_cloner_fetcher.cpp b/src/mongo/db/s/global_index/global_index_cloner_fetcher.cpp
index b12557caaca..03bfea8a74c 100644
--- a/src/mongo/db/s/global_index/global_index_cloner_fetcher.cpp
+++ b/src/mongo/db/s/global_index/global_index_cloner_fetcher.cpp
@@ -261,7 +261,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> GlobalIndexClonerFetcher::_restartPip
// recipient spent waiting for documents from the donor shards. It doing so requires the CurOp
// to be marked as having started.
auto* curOp = CurOp::get(opCtx);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
ON_BLOCK_EXIT([curOp] { curOp->done(); });
auto pipeline = _targetAggregationRequest(*makePipeline(opCtx));
diff --git a/src/mongo/db/s/periodic_sharded_index_consistency_checker.cpp b/src/mongo/db/s/periodic_sharded_index_consistency_checker.cpp
index 7a3b489674e..fb5b113216d 100644
--- a/src/mongo/db/s/periodic_sharded_index_consistency_checker.cpp
+++ b/src/mongo/db/s/periodic_sharded_index_consistency_checker.cpp
@@ -121,7 +121,7 @@ void PeriodicShardedIndexConsistencyChecker::_launchShardedIndexConsistencyCheck
auto uniqueOpCtx = client->makeOperationContext();
auto opCtx = uniqueOpCtx.get();
auto curOp = CurOp::get(opCtx);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
ON_BLOCK_EXIT([&] { curOp->done(); });
try {
diff --git a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
index 384c07ebb72..ff5f03d3a35 100644
--- a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
+++ b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
@@ -232,7 +232,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> ReshardingCollectionCloner::_restartP
// recipient spent waiting for documents from the donor shards. It doing so requires the CurOp
// to be marked as having started.
auto* curOp = CurOp::get(opCtx);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
ON_BLOCK_EXIT([curOp] { curOp->done(); });
auto pipeline = _targetAggregationRequest(
diff --git a/src/mongo/db/s/resharding/resharding_data_copy_util.cpp b/src/mongo/db/s/resharding/resharding_data_copy_util.cpp
index 5bfde9adf0d..912677b3854 100644
--- a/src/mongo/db/s/resharding/resharding_data_copy_util.cpp
+++ b/src/mongo/db/s/resharding/resharding_data_copy_util.cpp
@@ -214,7 +214,7 @@ std::vector<InsertStatement> fillBatchForInsert(Pipeline& pipeline, int batchSiz
// to be marked as having started.
auto opCtx = pipeline.getContext()->opCtx;
auto* curOp = CurOp::get(opCtx);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
ON_BLOCK_EXIT([curOp] { curOp->done(); });
std::vector<InsertStatement> batch;
diff --git a/src/mongo/db/s/resharding/resharding_txn_cloner.cpp b/src/mongo/db/s/resharding/resharding_txn_cloner.cpp
index 75c652f9bb8..8a015e52af5 100644
--- a/src/mongo/db/s/resharding/resharding_txn_cloner.cpp
+++ b/src/mongo/db/s/resharding/resharding_txn_cloner.cpp
@@ -157,7 +157,7 @@ boost::optional<SessionTxnRecord> ReshardingTxnCloner::_getNextRecord(OperationC
// recipient spent waiting for documents from the donor shard. It doing so requires the CurOp to
// be marked as having started.
auto* curOp = CurOp::get(opCtx);
- curOp->ensureStarted(opCtx);
+ curOp->ensureStarted();
ON_BLOCK_EXIT([curOp] { curOp->done(); });
auto doc = pipeline.getNext();
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 4a86de9a009..4b76185cf82 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -1538,7 +1538,7 @@ void ExecCommandDatabase::_initiateCommand() {
}
if (CommandHelpers::isHelpRequest(helpField)) {
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
// We disable not-primary-error tracker for help requests due to SERVER-11492, because
// config servers use help requests to determine which commands are database writes, and so
// must be forwarded to all config servers.
@@ -1742,7 +1742,7 @@ void ExecCommandDatabase::_initiateCommand() {
uassertStatusOK(status);
}
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
command->incrementCommandsExecuted();
@@ -2319,7 +2319,6 @@ void HandleRequest::completeOperation(DbResponse& response) {
// Mark the op as complete, and log it if appropriate. Returns a boolean indicating whether
// this op should be written to the profiler.
const bool shouldProfile = currentOp.completeAndLogOperation(
- opCtx,
MONGO_LOGV2_DEFAULT_COMPONENT,
CollectionCatalog::get(opCtx)
->getDatabaseProfileSettings(currentOp.getNSS().dbName())
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 4dd0006ea74..7fb56f08037 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -586,7 +586,7 @@ void ParseAndRunCommand::_parseCommand() {
(request.getDatabase() == *_ns ? NamespaceString(*_ns, "$cmd") : NamespaceString(*_ns));
// Fill out all currentOp details.
- CurOp::get(opCtx)->setGenericOpRequestDetails(opCtx, nss, command, request.body, _opType);
+ CurOp::get(opCtx)->setGenericOpRequestDetails(nss, command, request.body, _opType);
_osi.emplace(initializeOperationSessionInfo(opCtx,
request.body,
diff --git a/src/mongo/s/query/results_merger_test_fixture.cpp b/src/mongo/s/query/results_merger_test_fixture.cpp
index fe256d7e025..637c879e87b 100644
--- a/src/mongo/s/query/results_merger_test_fixture.cpp
+++ b/src/mongo/s/query/results_merger_test_fixture.cpp
@@ -76,7 +76,7 @@ void ResultsMergerTestFixture::setUp() {
setupShards(shards);
- CurOp::get(operationContext())->ensureStarted(operationContext());
+ CurOp::get(operationContext())->ensureStarted();
}
} // namespace mongo
diff --git a/src/mongo/s/service_entry_point_mongos.cpp b/src/mongo/s/service_entry_point_mongos.cpp
index 39f3f12e1b4..0dcabb98682 100644
--- a/src/mongo/s/service_entry_point_mongos.cpp
+++ b/src/mongo/s/service_entry_point_mongos.cpp
@@ -124,7 +124,7 @@ void HandleRequest::setupEnvironment() {
NotPrimaryErrorTracker::get(client).startRequest();
AuthorizationSession::get(client)->startRequest(opCtx);
- CurOp::get(opCtx)->ensureStarted(opCtx);
+ CurOp::get(opCtx)->ensureStarted();
}
struct HandleRequest::CommandOpRunner {
@@ -169,7 +169,6 @@ void HandleRequest::onSuccess(const DbResponse& dbResponse) {
// Mark the op as complete, populate the response length, and log it if appropriate.
currentOp->completeAndLogOperation(
- opCtx,
logv2::LogComponent::kCommand,
CollectionCatalog::get(opCtx)
->getDatabaseProfileSettings(currentOp->getNSS().dbName())