From d5bf63455aa614d98ac840f09ce5ca6b813b9507 Mon Sep 17 00:00:00 2001 From: Andy Schwerin Date: Fri, 15 May 2015 14:39:52 -0400 Subject: SERVER-18515 Replace OperationContext::getCurOp with CurOp::get(OperationContext*) --- src/mongo/SConscript | 4 ++-- src/mongo/db/catalog/capped_utils.cpp | 2 +- src/mongo/db/catalog/index_create.cpp | 4 ++-- src/mongo/db/clientlistplugin.cpp | 6 +++--- src/mongo/db/cloner.cpp | 2 +- src/mongo/db/commands/count.cpp | 4 ++-- src/mongo/db/commands/current_op.cpp | 10 ++++++---- src/mongo/db/commands/find_and_modify.cpp | 4 ++-- src/mongo/db/commands/find_cmd.cpp | 8 ++++---- src/mongo/db/commands/geo_near_cmd.cpp | 2 +- src/mongo/db/commands/getmore_cmd.cpp | 6 +++--- src/mongo/db/commands/mr.cpp | 4 ++-- src/mongo/db/commands/pipeline_command.cpp | 2 +- .../db/commands/write_commands/batch_executor.cpp | 12 ++++++------ .../db/commands/write_commands/write_commands.cpp | 2 +- src/mongo/db/concurrency/write_conflict_exception.h | 2 +- src/mongo/db/curop.cpp | 2 ++ src/mongo/db/curop.h | 3 +++ src/mongo/db/db_raii.cpp | 14 +++++++------- src/mongo/db/dbcommands.cpp | 16 ++++++++-------- src/mongo/db/dbhelpers.cpp | 2 +- src/mongo/db/index/index_access_method.cpp | 2 +- src/mongo/db/index_builder.cpp | 4 ++-- src/mongo/db/instance.cpp | 2 +- src/mongo/db/introspect.cpp | 10 +++++----- src/mongo/db/operation_context.h | 5 ----- src/mongo/db/operation_context_impl.cpp | 12 ++++-------- src/mongo/db/operation_context_impl.h | 2 -- src/mongo/db/operation_context_noop.h | 5 ----- src/mongo/db/query/explain.cpp | 2 +- src/mongo/db/query/plan_executor.cpp | 2 +- src/mongo/db/query/plan_yield_policy.cpp | 2 +- src/mongo/db/query/query_yield.cpp | 2 +- src/mongo/db/range_deleter_db_env.cpp | 2 +- src/mongo/db/repl/SConscript | 1 + src/mongo/db/repl/master_slave.cpp | 2 +- src/mongo/db/repl/sync_tail.cpp | 2 +- src/mongo/dbtests/indexupdatetests.cpp | 18 +++++++++--------- src/mongo/dbtests/query_stage_update.cpp | 6 +++--- src/mongo/dbtests/querytests.cpp | 2 +- src/mongo/s/d_migrate.cpp | 4 ++-- src/mongo/tools/SConscript | 4 ++-- src/mongo/tools/bridge.cpp | 4 ++++ src/mongo/util/net/ssl_manager.cpp | 7 +++---- src/mongo/util/progress_meter.h | 2 +- 45 files changed, 105 insertions(+), 110 deletions(-) diff --git a/src/mongo/SConscript b/src/mongo/SConscript index ed0a77ca53e..224f1f593f3 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -179,9 +179,9 @@ env.Install( "client/examples/mongoperf.cpp", ], LIBDEPS=[ - "util/ntservice_mock", - "db/serveronly", "db/coredb", + "db/serveronly", + "util/ntservice_mock", "util/signal_handlers_synchronous", ]), ]) diff --git a/src/mongo/db/catalog/capped_utils.cpp b/src/mongo/db/catalog/capped_utils.cpp index e155c03c6e9..b90edb2c432 100644 --- a/src/mongo/db/catalog/capped_utils.cpp +++ b/src/mongo/db/catalog/capped_utils.cpp @@ -217,7 +217,7 @@ namespace { retries = 0; } catch (const WriteConflictException& wce) { - txn->getCurOp()->debug().writeConflicts++; + CurOp::get(txn)->debug().writeConflicts++; retries++; // logAndBackoff expects this to be 1 on first call. wce.logAndBackoff(retries, "cloneCollectionAsCapped", fromNs); diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp index 31a32352a11..c069b0cc292 100644 --- a/src/mongo/db/catalog/index_create.cpp +++ b/src/mongo/db/catalog/index_create.cpp @@ -228,7 +228,7 @@ namespace mongo { invariant(_indexes.size() == 1); invariant(_buildInBackground); IndexDescriptor* descriptor = _indexes[0].block->getEntry()->descriptor(); - _collection->getIndexCatalog()->registerIndexBuild(descriptor, _txn->getCurOp()->opNum()); + _collection->getIndexCatalog()->registerIndexBuild(descriptor, CurOp::get(_txn)->opNum()); return descriptor; } @@ -300,7 +300,7 @@ namespace mongo { retries = 0; } catch (const WriteConflictException& wce) { - _txn->getCurOp()->debug().writeConflicts++; + CurOp::get(_txn)->debug().writeConflicts++; retries++; // logAndBackoff expects this to be 1 on first call. wce.logAndBackoff(retries, "index creation", _collection->ns().ns()); diff --git a/src/mongo/db/clientlistplugin.cpp b/src/mongo/db/clientlistplugin.cpp index 7f59234a27e..3cef57b041c 100644 --- a/src/mongo/db/clientlistplugin.cpp +++ b/src/mongo/db/clientlistplugin.cpp @@ -96,7 +96,7 @@ namespace { const OperationContext* txn = client->getOperationContext(); if (!txn) continue; - CurOp* curOp = txn->getCurOp(); + CurOp* curOp = CurOp::get(txn); if (!curOp) continue; ss << "" << client->desc() << ""; @@ -213,8 +213,8 @@ namespace { if (txn) { // CurOp - if (txn->getCurOp()) { - txn->getCurOp()->reportState(&b); + if (CurOp::get(txn)) { + CurOp::get(txn)->reportState(&b); } // LockState diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index eb1975b417c..5b92cadc8a7 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -174,7 +174,7 @@ namespace mongo { scopedXact.reset(); globalWriteLock.reset(); - txn->getCurOp()->yielded(); + CurOp::get(txn)->yielded(); scopedXact.reset(new ScopedTransaction(txn, MODE_X)); globalWriteLock.reset(new Lock::GlobalWrite(txn->lockState())); diff --git a/src/mongo/db/commands/count.cpp b/src/mongo/db/commands/count.cpp index 15700af1d42..9e63fff171a 100644 --- a/src/mongo/db/commands/count.cpp +++ b/src/mongo/db/commands/count.cpp @@ -142,8 +142,8 @@ namespace mongo { scoped_ptr exec(rawExec); // Store the plan summary string in CurOp. - if (NULL != txn->getCurOp()) { - txn->getCurOp()->debug().planSummary = Explain::getPlanSummary(exec.get()); + if (NULL != CurOp::get(txn)) { + CurOp::get(txn)->debug().planSummary = Explain::getPlanSummary(exec.get()); } Status execPlanStatus = exec->executePlan(); diff --git a/src/mongo/db/commands/current_op.cpp b/src/mongo/db/commands/current_op.cpp index 0bb4576c954..7d3957ea42f 100644 --- a/src/mongo/db/commands/current_op.cpp +++ b/src/mongo/db/commands/current_op.cpp @@ -111,9 +111,11 @@ namespace mongo { if (!includeAll) { // Skip over inactive connections. - if (!opCtx || !opCtx->getCurOp() || !opCtx->getCurOp()->active()) { + if (!opCtx) + continue; + auto curOp = CurOp::get(opCtx); + if (!curOp || !curOp->active()) continue; - } } BSONObjBuilder infoBuilder; @@ -124,8 +126,8 @@ namespace mongo { // Operation context specific information if (opCtx) { // CurOp - if (opCtx->getCurOp()) { - opCtx->getCurOp()->reportState(&infoBuilder); + if (CurOp::get(opCtx)) { + CurOp::get(opCtx)->reportState(&infoBuilder); } // LockState diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index c8726703b88..1a7aebbc9e1 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -366,7 +366,7 @@ namespace { return parsedUpdateStatus; } - OpDebug* opDebug = &txn->getCurOp()->debug(); + OpDebug* opDebug = &CurOp::get(txn)->debug(); // Explain calls of the findAndModify command are read-only, but we take write // locks so that the timing information is more accurate. @@ -491,7 +491,7 @@ namespace { return appendCommandStatus(result, parsedUpdateStatus); } - OpDebug* opDebug = &txn->getCurOp()->debug(); + OpDebug* opDebug = &CurOp::get(txn)->debug(); AutoGetOrCreateDb autoDb(txn, dbName, MODE_IX); Lock::CollectionLock collLock(txn->lockState(), nsString.ns(), MODE_IX); diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 73264590f42..02f383bd1cc 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -201,7 +201,7 @@ namespace mongo { } // Fill out curop information. - beginQueryOp(nss, cmdObj, lpq->getNumToReturn(), lpq->getSkip(), txn->getCurOp()); + beginQueryOp(nss, cmdObj, lpq->getNumToReturn(), lpq->getSkip(), CurOp::get(txn)); // 1b) Finish the parsing step by using the LiteParsedQuery to create a CanonicalQuery. std::unique_ptr cq; @@ -263,7 +263,7 @@ namespace mongo { const int numResults = 0; const CursorId cursorId = 0; endQueryOp(execHolder.get(), dbProfilingLevel, numResults, cursorId, - txn->getCurOp()); + CurOp::get(txn)); appendCursorResponseObject(cursorId, nss.ns(), BSONArray(), &result); return true; } @@ -325,7 +325,7 @@ namespace mongo { // State will be restored on getMore. exec->saveState(); - cursor->setLeftoverMaxTimeMicros(txn->getCurOp()->getRemainingMaxTimeMicros()); + cursor->setLeftoverMaxTimeMicros(CurOp::get(txn)->getRemainingMaxTimeMicros()); cursor->setPos(numResults); // Don't stash the RU for tailable cursors at EOF, let them get a new RU on their @@ -345,7 +345,7 @@ namespace mongo { } // Fill out curop based on the results. - endQueryOp(exec, dbProfilingLevel, numResults, cursorId, txn->getCurOp()); + endQueryOp(exec, dbProfilingLevel, numResults, cursorId, CurOp::get(txn)); // 7) Generate the response object to send to the client. appendCursorResponseObject(cursorId, nss.ns(), firstBatch.arr(), &result); diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp index d543772e0ae..42c608cb2d6 100644 --- a/src/mongo/db/commands/geo_near_cmd.cpp +++ b/src/mongo/db/commands/geo_near_cmd.cpp @@ -262,7 +262,7 @@ namespace mongo { stats.append("avgDistance", totalDistance / results); stats.append("maxDistance", farthestDist); - stats.append("time", txn->getCurOp()->elapsedMillis()); + stats.append("time", CurOp::get(txn)->elapsedMillis()); stats.done(); return true; diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index f69a14796a8..e89093dbf0b 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -194,7 +194,7 @@ namespace mongo { // If the operation that spawned this cursor had a time limit set, apply leftover // time to this getmore. - txn->getCurOp()->setMaxTimeMicros(cursor->getLeftoverMaxTimeMicros()); + CurOp::get(txn)->setMaxTimeMicros(cursor->getLeftoverMaxTimeMicros()); txn->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point. if (cursor->isAggCursor()) { @@ -239,7 +239,7 @@ namespace mongo { exec->saveState(); - cursor->setLeftoverMaxTimeMicros(txn->getCurOp()->getRemainingMaxTimeMicros()); + cursor->setLeftoverMaxTimeMicros(CurOp::get(txn)->getRemainingMaxTimeMicros()); cursor->incPos(numResults); if (isCursorTailable(cursor) && state == PlanExecutor::IS_EOF) { @@ -249,7 +249,7 @@ namespace mongo { } } else { - txn->getCurOp()->debug().cursorExhausted = true; + CurOp::get(txn)->debug().cursorExhausted = true; } appendGetMoreResponseObject(respondWithId, diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 532d5423cf5..5462e7abb93 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1298,7 +1298,7 @@ namespace mongo { "Cannot run mapReduce command from eval()")); } - CurOp* op = txn->getCurOp(); + CurOp* op = CurOp::get(txn); Config config( dbname , cmd ); @@ -1590,7 +1590,7 @@ namespace mongo { inputNS = dbname + "." + shardedOutputCollection; } - CurOp * op = txn->getCurOp(); + CurOp * op = CurOp::get(txn); Config config( dbname , cmdObj.firstElement().embeddedObjectUserCheck() ); State state(txn, config); diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index 571c3087254..e8ffde68217 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -129,7 +129,7 @@ namespace mongo { if (cursor) { // If a time limit was set on the pipeline, remaining time is "rolled over" to the // cursor (for use by future getmore ops). - cursor->setLeftoverMaxTimeMicros( txn->getCurOp()->getRemainingMaxTimeMicros() ); + cursor->setLeftoverMaxTimeMicros( CurOp::get(txn)->getRemainingMaxTimeMicros() ); if (txn->getClient()->isInDirectClient()) { cursor->setUnownedRecoveryUnit(txn->recoveryUnit()); diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index 13305866af4..ce52fa66ab4 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -250,7 +250,7 @@ namespace mongo { if ( needToEnforceWC ) { - _txn->getCurOp()->setMessage( "waiting for write concern" ); + CurOp::get(_txn)->setMessage( "waiting for write concern" ); WriteConcernResult res; Status status = waitForWriteConcern( @@ -622,7 +622,7 @@ namespace mongo { } if (currentOp->shouldDBProfile(executionTime)) { - profile(txn, txn->getCurOp()->getOp()); + profile(txn, CurOp::get(txn)->getOp()); } } @@ -993,7 +993,7 @@ namespace mongo { bool intentLock) { if (hasLock()) { // TODO: OldClientContext legacy, needs to be removed - txn->getCurOp()->enter(_context->ns(), + CurOp::get(txn)->enter(_context->ns(), _context->db() ? _context->db()->getProfilingLevel() : 0); return true; } @@ -1102,7 +1102,7 @@ namespace mongo { } catch ( const WriteConflictException& wce ) { state->unlock(); - state->txn->getCurOp()->debug().writeConflicts++; + CurOp::get(state->txn)->debug().writeConflicts++; state->txn->recoveryUnit()->abandonSnapshot(); WriteConflictException::logAndBackoff( attempt++, "insert", @@ -1334,7 +1334,7 @@ namespace mongo { continue; } - OpDebug* debug = &txn->getCurOp()->debug(); + OpDebug* debug = &CurOp::get(txn)->debug(); try { invariant(collection); @@ -1456,7 +1456,7 @@ namespace mongo { break; } catch ( const WriteConflictException& dle ) { - txn->getCurOp()->debug().writeConflicts++; + CurOp::get(txn)->debug().writeConflicts++; WriteConflictException::logAndBackoff( attempt++, "delete", nss.ns() ); } catch (const StaleConfigException& staleExcep) { diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp index a1d217d7525..d28b9c80bba 100644 --- a/src/mongo/db/commands/write_commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands/write_commands.cpp @@ -212,7 +212,7 @@ namespace mongo { // Explained updates can yield. updateRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO); - OpDebug* debug = &txn->getCurOp()->debug(); + OpDebug* debug = &CurOp::get(txn)->debug(); ParsedUpdate parsedUpdate( txn, &updateRequest ); Status parseStatus = parsedUpdate.parseRequest(); diff --git a/src/mongo/db/concurrency/write_conflict_exception.h b/src/mongo/db/concurrency/write_conflict_exception.h index 9ebe9c4cb60..e94eab741d7 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.h +++ b/src/mongo/db/concurrency/write_conflict_exception.h @@ -38,7 +38,7 @@ #define MONGO_WRITE_CONFLICT_RETRY_LOOP_END(PTXN, OPSTR, NSSTR) \ catch (const ::mongo::WriteConflictException &wce) { \ const OperationContext* ptxn = (PTXN); \ - ++ptxn->getCurOp()->debug().writeConflicts; \ + ++CurOp::get(ptxn)->debug().writeConflicts; \ wce.logAndBackoff(wcr__Attempts, (OPSTR), (NSSTR)); \ ++wcr__Attempts; \ ptxn->recoveryUnit()->abandonSnapshot(); \ diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 06c86a71941..8ede1ff1c1f 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -146,6 +146,8 @@ namespace mongo { CurOp* CurOp::get(const Client* client) { return _curopStack(client).top(); } CurOp* CurOp::get(const Client& client) { return _curopStack(client).top(); } + CurOp* CurOp::get(const OperationContext* opCtx) { return get(opCtx->getClient()); } + CurOp* CurOp::get(const OperationContext& opCtx) { return get(opCtx.getClient()); } CurOp::CurOp(Client* client) : CurOp(client, &_curopStack(client)) {} diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 634a897c16e..06fe40452e3 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -48,6 +48,7 @@ namespace mongo { class Client; class Command; class CurOp; + class OperationContext; /** * stores a copy of a bson obj in a fixed size buffer @@ -196,6 +197,8 @@ namespace mongo { public: static CurOp* get(const Client* client); static CurOp* get(const Client& client); + static CurOp* get(const OperationContext* opCtx); + static CurOp* get(const OperationContext& opCtx); explicit CurOp(Client* client); ~CurOp(); diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp index 937b474ebb2..5a78f2d7d90 100644 --- a/src/mongo/db/db_raii.cpp +++ b/src/mongo/db/db_raii.cpp @@ -86,8 +86,8 @@ namespace mongo { massert(28535, "need a non-empty collection name", !coll.empty()); // TODO: OldClientContext legacy, needs to be removed - _txn->getCurOp()->ensureStarted(); - _txn->getCurOp()->setNS(ns); + CurOp::get(_txn)->ensureStarted(); + CurOp::get(_txn)->setNS(ns); // We have both the DB and collection locked, which the prerequisite to do a stable shard // version check. @@ -97,7 +97,7 @@ namespace mongo { // constructor, so it is safe to load the DB pointer. if (_db.getDb()) { // TODO: OldClientContext legacy, needs to be removed - _txn->getCurOp()->enter(ns.c_str(), _db.getDb()->getProfilingLevel()); + CurOp::get(_txn)->enter(ns.c_str(), _db.getDb()->getProfilingLevel()); _coll = _db.getDb()->getCollection(ns); } @@ -105,7 +105,7 @@ namespace mongo { AutoGetCollectionForRead::~AutoGetCollectionForRead() { // Report time spent in read lock - _txn->getCurOp()->recordGlobalTime(false, _timer.micros()); + CurOp::get(_txn)->recordGlobalTime(false, _timer.micros()); } @@ -156,11 +156,11 @@ namespace mongo { _checkNotStale(); } - _txn->getCurOp()->enter(_ns.c_str(), _db->getProfilingLevel()); + CurOp::get(_txn)->enter(_ns.c_str(), _db->getProfilingLevel()); } void OldClientContext::_checkNotStale() const { - switch (_txn->getCurOp()->getOp()) { + switch (CurOp::get(_txn)->getOp()) { case dbGetMore: // getMore is special and should be handled elsewhere. case dbUpdate: // update & delete check shard version in instance.cpp, so don't check case dbDelete: // here as well. @@ -174,7 +174,7 @@ namespace mongo { // Lock must still be held invariant(_txn->lockState()->isLocked()); - _txn->getCurOp()->recordGlobalTime(_txn->lockState()->isWriteLocked(), _timer.micros()); + CurOp::get(_txn)->recordGlobalTime(_txn->lockState()->isWriteLocked(), _timer.micros()); } diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 192c883a050..3aaaf967107 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -1018,8 +1018,8 @@ namespace mongo { const string ns = parseNs(dbname, jsobj); // TODO: OldClientContext legacy, needs to be removed - txn->getCurOp()->ensureStarted(); - txn->getCurOp()->setNS(dbname); + CurOp::get(txn)->ensureStarted(); + CurOp::get(txn)->setNS(dbname); // We lock the entire database in S-mode in order to ensure that the contents will not // change for the stats snapshot. This might be unnecessary and if it becomes a @@ -1048,7 +1048,7 @@ namespace mongo { } else { // TODO: OldClientContext legacy, needs to be removed - txn->getCurOp()->enter(dbname.c_str(), db->getProfilingLevel()); + CurOp::get(txn)->enter(dbname.c_str(), db->getProfilingLevel()); db->getStats(txn, &result, scale); } @@ -1078,7 +1078,7 @@ namespace mongo { int, string& errmsg, BSONObjBuilder& result) { - result << "you" << txn->getCurOp()->getRemoteString(); + result << "you" << CurOp::get(txn)->getRemoteString(); return true; } } cmdWhatsMyUri; @@ -1216,7 +1216,7 @@ namespace { scoped_ptr mmSetter; if ( cmdObj["help"].trueValue() ) { - txn->getCurOp()->ensureStarted(); + CurOp::get(txn)->ensureStarted(); stringstream ss; ss << "help for: " << c->name << " "; c->help( ss ); @@ -1295,7 +1295,7 @@ namespace { LOG( 2 ) << "command: " << cmdObj << endl; } - txn->getCurOp()->setCommand(c); + CurOp::get(txn)->setCommand(c); if (c->maintenanceMode()) { mmSetter.reset(new MaintenanceModeSetter); @@ -1319,7 +1319,7 @@ namespace { return; } - txn->getCurOp()->setMaxTimeMicros(static_cast(maxTimeMS.getValue()) + CurOp::get(txn)->setMaxTimeMicros(static_cast(maxTimeMS.getValue()) * 1000); try { txn->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point. @@ -1332,7 +1332,7 @@ namespace { std::string errmsg; bool retval = false; - txn->getCurOp()->ensureStarted(); + CurOp::get(txn)->ensureStarted(); c->_commandsExecuted.increment(); diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp index 24be8b1f4f3..fe7e0f53952 100644 --- a/src/mongo/db/dbhelpers.cpp +++ b/src/mongo/db/dbhelpers.cpp @@ -206,7 +206,7 @@ namespace mongo { auto_ptr exec(InternalPlanner::collectionScan(txn, ns, ctx.getCollection())); PlanExecutor::ExecState state = exec->getNext(&result, NULL); - txn->getCurOp()->done(); + CurOp::get(txn)->done(); if (PlanExecutor::ADVANCED == state) { result = result.getOwned(); diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 1f373090288..e04593cd27e 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -436,7 +436,7 @@ namespace mongo { pm.finished(); - txn->getCurOp()->setMessage("Index Bulk Build: (3/3) btree-middle", + CurOp::get(txn)->setMessage("Index Bulk Build: (3/3) btree-middle", "Index: (3/3) BTree Middle Progress"); LOG(timer.seconds() > 10 ? 0 : 1 ) << "\t done building bottom layer, going to commit"; diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index 6d71ffb185e..1467d8c71a7 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -87,7 +87,7 @@ namespace { AuthorizationSession::get(txn.getClient())->grantInternalAuthorization(); - txn.getCurOp()->reset(HostAndPort(), dbInsert); + CurOp::get(txn)->reset(HostAndPort(), dbInsert); NamespaceString ns(_index["ns"].String()); ScopedTransaction transaction(&txn, MODE_IX); @@ -142,7 +142,7 @@ namespace { } // Show which index we're building in the curop display. - txn->getCurOp()->setQuery(_index); + CurOp::get(txn)->setQuery(_index); bool haveSetBgIndexStarting = false; while (true) { diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index ccab80871d4..02cd792bf89 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -995,7 +995,7 @@ namespace { break; } catch( const WriteConflictException& e ) { - txn->getCurOp()->debug().writeConflicts++; + CurOp::get(txn)->debug().writeConflicts++; txn->recoveryUnit()->abandonSnapshot(); WriteConflictException::logAndBackoff( attempt++, "insert", ns); } diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp index 8040a0b7b6b..1f6e0003e6c 100644 --- a/src/mongo/db/introspect.cpp +++ b/src/mongo/db/introspect.cpp @@ -91,20 +91,20 @@ namespace { { Locker::LockerInfo lockerInfo; txn->lockState()->getLockerInfo(&lockerInfo); - txn->getCurOp()->debug().append(*txn->getCurOp(), lockerInfo.stats, b); + CurOp::get(txn)->debug().append(*CurOp::get(txn), lockerInfo.stats, b); } b.appendDate("ts", jsTime()); b.append("client", txn->getClient()->clientAddress()); AuthorizationSession * authSession = AuthorizationSession::get(txn->getClient()); - _appendUserInfo(*txn->getCurOp(), b, authSession); + _appendUserInfo(*CurOp::get(txn), b, authSession); const BSONObj p = b.done(); const bool wasLocked = txn->lockState()->isLocked(); - const string dbName(nsToDatabase(txn->getCurOp()->getNS())); + const string dbName(nsToDatabase(CurOp::get(txn)->getNS())); try { bool acquireDbXLock = false; @@ -126,7 +126,7 @@ namespace { if (!db) { // Database disappeared log() << "note: not profiling because db went away for " - << txn->getCurOp()->getNS(); + << CurOp::get(txn)->getNS(); break; } @@ -156,7 +156,7 @@ namespace { catch (const AssertionException& assertionEx) { warning() << "Caught Assertion while trying to profile " << opToString(op) - << " against " << txn->getCurOp()->getNS() + << " against " << CurOp::get(txn)->getNS() << ": " << assertionEx.toString() << endl; } } diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index 121b3774772..0717745e858 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -134,11 +134,6 @@ namespace mongo { */ virtual Client* getClient() const = 0; - /** - * Returns CurOp. Caller does not own pointer - */ - virtual CurOp* getCurOp() const = 0; - virtual uint64_t getRemainingMaxTimeMicros() const = 0; /** diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp index 00f89395527..fa90259dbc4 100644 --- a/src/mongo/db/operation_context_impl.cpp +++ b/src/mongo/db/operation_context_impl.cpp @@ -119,27 +119,23 @@ namespace { const std::string &name, unsigned long long progressMeterTotal, int secondsBetween) { - return &getCurOp()->setMessage(msg, name, progressMeterTotal, secondsBetween); + return &CurOp::get(this)->setMessage(msg, name, progressMeterTotal, secondsBetween); } string OperationContextImpl::getNS() const { - return getCurOp()->getNS(); + return CurOp::get(this)->getNS(); } Client* OperationContextImpl::getClient() const { return _client; } - CurOp* OperationContextImpl::getCurOp() const { - return CurOp::get(getClient()); - } - unsigned int OperationContextImpl::getOpID() const { - return getCurOp()->opNum(); + return CurOp::get(this)->opNum(); } uint64_t OperationContextImpl::getRemainingMaxTimeMicros() const { - return getCurOp()->getRemainingMaxTimeMicros(); + return CurOp::get(this)->getRemainingMaxTimeMicros(); } // Enabling the checkForInterruptFail fail point will start a game of random chance on the diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h index 86a5f3af870..a904400648a 100644 --- a/src/mongo/db/operation_context_impl.h +++ b/src/mongo/db/operation_context_impl.h @@ -58,8 +58,6 @@ namespace mongo { virtual Client* getClient() const override; - virtual CurOp* getCurOp() const override; - virtual unsigned int getOpID() const override; virtual uint64_t getRemainingMaxTimeMicros() const override; diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h index aaf9cc012bc..a428042438c 100644 --- a/src/mongo/db/operation_context_noop.h +++ b/src/mongo/db/operation_context_noop.h @@ -58,11 +58,6 @@ namespace mongo { return NULL; } - virtual CurOp* getCurOp() const override { - invariant(false); - return NULL; - } - virtual RecoveryUnit* recoveryUnit() const override { return _recoveryUnit.get(); } diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp index b9a18f62067..6915511925a 100644 --- a/src/mongo/db/query/explain.cpp +++ b/src/mongo/db/query/explain.cpp @@ -647,7 +647,7 @@ namespace mongo { // Generate exec stats BSON for the winning plan. OperationContext* opCtx = exec->getOpCtx(); - long long totalTimeMillis = opCtx->getCurOp()->elapsedMillis(); + long long totalTimeMillis = CurOp::get(opCtx)->elapsedMillis(); generateExecStats(winningStats.get(), verbosity, &execBob, totalTimeMillis); // Also generate exec stats for all plans, if the verbosity level is high enough. diff --git a/src/mongo/db/query/plan_executor.cpp b/src/mongo/db/query/plan_executor.cpp index 84e7bad0300..cd9d2478df0 100644 --- a/src/mongo/db/query/plan_executor.cpp +++ b/src/mongo/db/query/plan_executor.cpp @@ -415,7 +415,7 @@ namespace mongo { else if (PlanStage::NEED_YIELD == code) { if (id == WorkingSet::INVALID_ID) { if (!_yieldPolicy->allowedToYield()) throw WriteConflictException(); - _opCtx->getCurOp()->debug().writeConflicts++; + CurOp::get(_opCtx)->debug().writeConflicts++; writeConflictsInARow++; WriteConflictException::logAndBackoff(writeConflictsInARow, "plan execution", diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp index 85cde44cf50..67eb574ef5c 100644 --- a/src/mongo/db/query/plan_yield_policy.cpp +++ b/src/mongo/db/query/plan_yield_policy.cpp @@ -100,7 +100,7 @@ namespace mongo { return _planYielding->restoreStateWithoutRetrying(opCtx); } catch (const WriteConflictException& wce) { - opCtx->getCurOp()->debug().writeConflicts++; + CurOp::get(opCtx)->debug().writeConflicts++; WriteConflictException::logAndBackoff(attempt, "plan execution restoreState", _planYielding->collection()->ns().ns()); diff --git a/src/mongo/db/query/query_yield.cpp b/src/mongo/db/query/query_yield.cpp index 5d6994d7eb6..5bd1733f0c6 100644 --- a/src/mongo/db/query/query_yield.cpp +++ b/src/mongo/db/query/query_yield.cpp @@ -63,7 +63,7 @@ namespace mongo { txn->recoveryUnit()->abandonSnapshot(); // Track the number of yields in CurOp. - txn->getCurOp()->yielded(); + CurOp::get(txn)->yielded(); if (fetcher) { fetcher->fetch(); diff --git a/src/mongo/db/range_deleter_db_env.cpp b/src/mongo/db/range_deleter_db_env.cpp index 5756d97616a..a73c1070ca7 100644 --- a/src/mongo/db/range_deleter_db_env.cpp +++ b/src/mongo/db/range_deleter_db_env.cpp @@ -90,7 +90,7 @@ namespace mongo { } // log the opId so the user can use it to cancel the delete using killOp. - unsigned int opId = txn->getCurOp()->opNum(); + unsigned int opId = CurOp::get(txn)->opNum(); log() << "Deleter starting delete for: " << ns << " from " << inclusiveLower << " -> " << exclusiveUpper diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index 8977bebd815..8eb930e7511 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -452,6 +452,7 @@ env.Library( LIBDEPS=[ '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/concurrency/write_conflict_exception', + '$BUILD_DIR/mongo/db/curop', ], ) diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index 2b5235bcc46..2a4ead26334 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -758,7 +758,7 @@ namespace repl { // mongos will not send requests there. That's why the last argument is false (do not do // version checking). OldClientContext ctx(txn, ns, false); - txn->getCurOp()->reset(); + CurOp::get(txn)->reset(); bool empty = !ctx.db()->getDatabaseCatalogEntry()->hasUserData(); bool incompleteClone = incompleteCloneDbs.count( clientName ) != 0; diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index 0938eda2e27..b50ca590eb2 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -132,7 +132,7 @@ namespace repl { } // Count each log op application as a separate operation, for reporting purposes - txn->getCurOp()->reset(); + CurOp::get(txn)->reset(); const char *ns = op.getStringField("ns"); verify(ns); diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp index cf01a43a9b1..a9cda7a01b6 100644 --- a/src/mongo/dbtests/indexupdatetests.cpp +++ b/src/mongo/dbtests/indexupdatetests.cpp @@ -175,7 +175,7 @@ namespace IndexUpdateTests { nDocs, nDocs)); // Register a request to kill the current operation. - txn.getCurOp()->kill(); + CurOp::get(txn)->kill(); if ( _mayInterrupt ) { // Add keys to phaseOne. ASSERT_THROWS( BtreeBasedBuilder::addKeysToPhaseOne( collection(), @@ -225,7 +225,7 @@ namespace IndexUpdateTests { phaseOne.sorter->sort( false ); // Set up remaining arguments. set dups; - CurOp* op = txn.getCurOp(); + CurOp* op = CurOp::get(txn); ProgressMeterHolder pm (op->setMessage("BuildBottomUp", "BuildBottomUp Progress", nKeys, @@ -291,7 +291,7 @@ namespace IndexUpdateTests { phaseOne.sorter->sort( false ); // Set up remaining arguments. set dups; - CurOp* op = txn.getCurOp(); + CurOp* op = CurOp::get(txn); ProgressMeterHolder pm (op->setMessage("InterruptBuildBottomUp", "InterruptBuildBottomUp Progress", nKeys, @@ -301,7 +301,7 @@ namespace IndexUpdateTests { // The index's root has not yet been set. ASSERT( id->getHead().isNull() ); // Register a request to kill the current operation. - txn.getCurOp()->kill(); + CurOp::get(txn)->kill(); if ( _mayInterrupt ) { // The build is aborted due to the kill request. ASSERT_THROWS @@ -483,7 +483,7 @@ namespace IndexUpdateTests { wunit.commit(); } // Initialize curop. - _txn.getCurOp()->reset(); + CurOp::get(_txn)->reset(); // Request an interrupt. getGlobalServiceContext()->setKillAllOperations(); BSONObj indexInfo = BSON( "key" << BSON( "a" << 1 ) << "ns" << _ns << "name" << "a_1" ); @@ -516,7 +516,7 @@ namespace IndexUpdateTests { wunit.commit(); } // Initialize curop. - _txn.getCurOp()->reset(); + CurOp::get(_txn)->reset(); // Request an interrupt. getGlobalServiceContext()->setKillAllOperations(); BSONObj indexInfo = BSON( "key" << BSON( "a" << 1 ) << "ns" << _ns << "name" << "a_1" ); @@ -552,7 +552,7 @@ namespace IndexUpdateTests { wunit.commit(); } // Initialize curop. - _txn.getCurOp()->reset(); + CurOp::get(_txn)->reset(); // Request an interrupt. getGlobalServiceContext()->setKillAllOperations(); BSONObj indexInfo = BSON( "key" << BSON( "_id" << 1 ) << @@ -590,7 +590,7 @@ namespace IndexUpdateTests { wunit.commit(); } // Initialize curop. - _txn.getCurOp()->reset(); + CurOp::get(_txn)->reset(); // Request an interrupt. getGlobalServiceContext()->setKillAllOperations(); BSONObj indexInfo = BSON( "key" << BSON( "_id" << 1 ) << @@ -617,7 +617,7 @@ namespace IndexUpdateTests { // Start with just _id ASSERT_EQUALS( 1U, _client.getIndexSpecs(_ns).size()); // Initialize curop. - _txn.getCurOp()->reset(); + CurOp::get(_txn)->reset(); // Request an interrupt. getGlobalServiceContext()->setKillAllOperations(); // The call is not interrupted. diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp index 0e800166807..783db28ca8b 100644 --- a/src/mongo/dbtests/query_stage_update.cpp +++ b/src/mongo/dbtests/query_stage_update.cpp @@ -372,7 +372,7 @@ namespace QueryStageUpdate { // Various variables we'll need. OldClientWriteContext ctx(&_txn, ns()); - OpDebug* opDebug = &_txn.getCurOp()->debug(); + OpDebug* opDebug = &CurOp::get(_txn)->debug(); Collection* coll = ctx.getCollection(); UpdateLifecycleImpl updateLifecycle(false, nsString()); UpdateRequest request(nsString()); @@ -459,7 +459,7 @@ namespace QueryStageUpdate { // Various variables we'll need. OldClientWriteContext ctx(&_txn, ns()); - OpDebug* opDebug = &_txn.getCurOp()->debug(); + OpDebug* opDebug = &CurOp::get(_txn)->debug(); Collection* coll = ctx.getCollection(); UpdateLifecycleImpl updateLifecycle(false, nsString()); UpdateRequest request(nsString()); @@ -540,7 +540,7 @@ namespace QueryStageUpdate { void run() { // Various variables we'll need. OldClientWriteContext ctx(&_txn, ns()); - OpDebug* opDebug = &_txn.getCurOp()->debug(); + OpDebug* opDebug = &CurOp::get(_txn)->debug(); Collection* coll = ctx.getCollection(); UpdateLifecycleImpl updateLifecycle(false, nsString()); UpdateRequest request(nsString()); diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index e804fc12e50..bc07e1f9231 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -217,7 +217,7 @@ namespace QueryTests { public: ClientBase() : _client(&_txn) { mongo::LastError::get(_txn.getClient()).reset(); - _txn.getCurOp()->reset(); + CurOp::get(_txn)->reset(); } virtual ~ClientBase() { mongo::LastError::get(_txn.getClient()).reset(); diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index 38c0b76ea7f..0ea779067bd 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -200,7 +200,7 @@ namespace mongo { ss << "step " << step << " of " << _total; string s = ss.str(); - CurOp * op = _txn->getCurOp(); + CurOp * op = CurOp::get(_txn); if ( op ) op->setMessage( s.c_str() ); else @@ -2658,7 +2658,7 @@ namespace mongo { } // Make curop active so this will show up in currOp. - txn.getCurOp()->reset(); + CurOp::get(txn)->reset(); migrateStatus.go(&txn, ns, min, max, shardKeyPattern, fromShard, epoch, writeConcern); } diff --git a/src/mongo/tools/SConscript b/src/mongo/tools/SConscript index d1f4360d040..47978407466 100644 --- a/src/mongo/tools/SConscript +++ b/src/mongo/tools/SConscript @@ -10,8 +10,8 @@ mongobridge = env.Program( "mongobridge_options_init.cpp" ], LIBDEPS=[ - "$BUILD_DIR/mongo/db/coredb", - "$BUILD_DIR/mongo/db/serveronly", + "$BUILD_DIR/mongo/client/clientdriver", + "$BUILD_DIR/mongo/util/net/network", "$BUILD_DIR/mongo/util/ntservice_mock", "$BUILD_DIR/mongo/util/options_parser/options_parser_init", "$BUILD_DIR/mongo/util/signal_handlers_synchronous", diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp index a2f72bf4ac5..2d00d6f644b 100644 --- a/src/mongo/tools/bridge.cpp +++ b/src/mongo/tools/bridge.cpp @@ -49,6 +49,10 @@ using namespace mongo; using namespace std; +namespace mongo { +bool inShutdown() { return false; } +} // namespace mongo + void cleanup( int sig ); class Forwarder { diff --git a/src/mongo/util/net/ssl_manager.cpp b/src/mongo/util/net/ssl_manager.cpp index 652807e7e71..d989d3b5559 100644 --- a/src/mongo/util/net/ssl_manager.cpp +++ b/src/mongo/util/net/ssl_manager.cpp @@ -693,10 +693,9 @@ namespace mongo { return false; } - if ((notBeforeMillis > curTimeMillis64()) || - (curTimeMillis64() > notAfterMillis)) { - dbexit(EXIT_BADOPTIONS, - "The provided SSL certificate is expired or not yet valid."); + if ((notBeforeMillis > curTimeMillis64()) || (curTimeMillis64() > notAfterMillis)) { + severe() << "The provided SSL certificate is expired or not yet valid."; + fassertFailedNoTrace(28652); } *serverCertificateExpirationDate = Date_t::fromMillisSinceEpoch(notAfterMillis); diff --git a/src/mongo/util/progress_meter.h b/src/mongo/util/progress_meter.h index 8b3adb9e633..bdcc83ddd14 100644 --- a/src/mongo/util/progress_meter.h +++ b/src/mongo/util/progress_meter.h @@ -107,7 +107,7 @@ namespace mongo { }; // e.g.: - // CurOp * op = txn.getCurOp(); + // CurOp * op = CurOp::get(txn); // ProgressMeterHolder pm(op->setMessage("index: (1/3) external sort", "Index: External Sort Progress", d->stats.nrecords, 10)); // loop { pm.hit(); } class ProgressMeterHolder : boost::noncopyable { -- cgit v1.2.1