diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-07-01 03:56:39 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-07-01 09:04:58 -0400 |
commit | f64357e485c8d46bd6fd393f7416df6117672de1 (patch) | |
tree | a90f2bb933dd4a1c2e774ac4e280e8ce7dbcbaeb /src/mongo/db/commands | |
parent | e7e24a657b64fa59c30b063c72ff4cbee9674b7e (diff) | |
download | mongo-f64357e485c8d46bd6fd393f7416df6117672de1.tar.gz |
SERVER-13961 Add OperationContext argument to Client::Context
Time tracking and database access in Client::Context require access to the
OperationContext. Adding it as argument.
This is in preparation for removing LockState from Client.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r-- | src/mongo/db/commands/apply_ops.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/collection_to_capped.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/compact.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/count.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/cpuprofile.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/drop_indexes.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/find_and_modify.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/commands/rename_collection.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/commands/test_commands.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/batch_executor.cpp | 10 |
11 files changed, 32 insertions, 31 deletions
diff --git a/src/mongo/db/commands/apply_ops.cpp b/src/mongo/db/commands/apply_ops.cpp index 88c8c66f484..b3fa1b6ce2e 100644 --- a/src/mongo/db/commands/apply_ops.cpp +++ b/src/mongo/db/commands/apply_ops.cpp @@ -133,7 +133,7 @@ namespace mongo { Lock::DBWrite lk(txn->lockState(), ns); invariant(txn->lockState()->isRecursive()); - Client::Context ctx(ns); + Client::Context ctx(txn, ns); bool failed = repl::applyOperation_inlock(txn, ctx.db(), temp, diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp index 7299f0abf29..476d80edf08 100644 --- a/src/mongo/db/commands/collection_to_capped.cpp +++ b/src/mongo/db/commands/collection_to_capped.cpp @@ -60,7 +60,7 @@ namespace mongo { // create new collection { - Client::Context ctx( toNs ); + Client::Context ctx(txn, toNs ); BSONObjBuilder spec; spec.appendBool( "capped", true ); spec.append( "size", size ); @@ -153,7 +153,7 @@ namespace mongo { } Lock::DBWrite dbXLock(txn->lockState(), dbname); - Client::Context ctx(dbname); + Client::Context ctx(txn, dbname); Status status = cloneCollectionAsCapped( txn, ctx.db(), from, to, size, temp, true ); return appendCommandStatus( result, status ); @@ -200,7 +200,7 @@ namespace mongo { // calls renamecollection which does a global lock, so we must too: // Lock::GlobalWrite globalWriteLock(txn->lockState()); - Client::Context ctx(dbname); + Client::Context ctx(txn, dbname); Database* db = ctx.db(); diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp index e9d4ca106d8..c0df090d29a 100644 --- a/src/mongo/db/commands/compact.cpp +++ b/src/mongo/db/commands/compact.cpp @@ -142,7 +142,7 @@ namespace mongo { Lock::DBWrite lk(txn->lockState(), ns.ns()); BackgroundOperation::assertNoBgOpInProgForNs(ns.ns()); - Client::Context ctx(ns); + Client::Context ctx(txn, ns); Collection* collection = ctx.db()->getCollection(txn, ns.ns()); if( ! collection ) { diff --git a/src/mongo/db/commands/count.cpp b/src/mongo/db/commands/count.cpp index 48ebb4422e1..aa43882ea78 100644 --- a/src/mongo/db/commands/count.cpp +++ b/src/mongo/db/commands/count.cpp @@ -73,7 +73,7 @@ namespace mongo { string &err, int &errCode) { // Lock 'ns'. - Client::Context cx(ns); + Client::Context cx(txn, ns); Collection* collection = cx.db()->getCollection(txn, ns); if (NULL == collection) { diff --git a/src/mongo/db/commands/cpuprofile.cpp b/src/mongo/db/commands/cpuprofile.cpp index b6c6f923f83..de614b8a553 100644 --- a/src/mongo/db/commands/cpuprofile.cpp +++ b/src/mongo/db/commands/cpuprofile.cpp @@ -136,7 +136,7 @@ namespace mongo { BSONObjBuilder &result, bool fromRepl ) { Lock::DBWrite dbXLock(db); - Client::Context ctx(db); + Client::Context ctx(txn, db); std::string profileFilename = cmdObj[commandName]["profileFilename"].String(); if ( ! ::ProfilerStart( profileFilename.c_str() ) ) { @@ -154,7 +154,7 @@ namespace mongo { BSONObjBuilder &result, bool fromRepl ) { Lock::DBWrite dbXLock(db); - Client::Context ctx(db); + Client::Context ctx(txn, db); ::ProfilerStop(); return true; diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index c659454d684..d5491d166e7 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -110,7 +110,7 @@ namespace mongo { LOG(0) << "CMD: dropIndexes " << toDeleteNs << endl; } - Client::Context ctx(toDeleteNs); + Client::Context ctx(txn, toDeleteNs); Database* db = ctx.db(); Collection* collection = db->getCollection( txn, toDeleteNs ); @@ -222,7 +222,7 @@ namespace mongo { LOG(0) << "CMD: reIndex " << toDeleteNs << endl; Lock::DBWrite dbXLock(txn->lockState(), dbname); - Client::Context ctx(toDeleteNs); + Client::Context ctx(txn, toDeleteNs); Collection* collection = ctx.db()->getCollection( txn, toDeleteNs ); diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index 7c3221cbbb6..3981705ed00 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -94,7 +94,7 @@ namespace mongo { } Lock::DBWrite dbXLock(txn->lockState(), dbname); - Client::Context ctx(ns); + Client::Context ctx(txn, ns); return runNoDirectClient( txn, ns , query , fields , update , @@ -134,7 +134,7 @@ namespace mongo { string& errmsg) { Lock::DBWrite lk(txn->lockState(), ns); - Client::Context cx( ns ); + Client::Context cx(txn, ns); Collection* collection = cx.db()->getCollection( txn, ns ); const WhereCallbackReal whereCallback = WhereCallbackReal(StringData(ns)); @@ -330,7 +330,7 @@ namespace mongo { } Lock::DBWrite dbXLock(txn->lockState(), dbname); - Client::Context ctx(ns); + Client::Context ctx(txn, ns); BSONObj out = db.findOne(ns, q, fields); if (out.isEmpty()) { diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 38dbceefe4d..b359a6fa3e4 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -588,7 +588,7 @@ namespace mongo { bool found; { - Client::Context tx( _config.outputOptions.finalNamespace ); + Client::Context tx(txn, _config.outputOptions.finalNamespace); Collection* coll = tx.db()->getCollection(_txn, _config.outputOptions.finalNamespace); found = Helpers::findOne(_txn, @@ -1290,7 +1290,7 @@ namespace mongo { // This context does no version check, safe b/c we checked earlier and have an // open cursor - scoped_ptr<Client::Context> ctx(new Client::Context(config.ns, false)); + scoped_ptr<Client::Context> ctx(new Client::Context(txn, config.ns, false)); const NamespaceString nss(config.ns); const WhereCallbackReal whereCallback(nss.db()); @@ -1349,7 +1349,8 @@ namespace mongo { lock.reset(); state.reduceAndSpillInMemoryStateIfNeeded(); lock.reset(new Lock::DBRead(txn->lockState(), config.ns)); - ctx.reset(new Client::Context(config.ns, false)); + + ctx.reset(new Client::Context(txn, config.ns, false)); reduceTime += t.micros(); diff --git a/src/mongo/db/commands/rename_collection.cpp b/src/mongo/db/commands/rename_collection.cpp index bae48fcc17f..a25b2e19a09 100644 --- a/src/mongo/db/commands/rename_collection.cpp +++ b/src/mongo/db/commands/rename_collection.cpp @@ -139,7 +139,7 @@ namespace mongo { std::vector<BSONObj> indexesInProg; { - Client::Context srcCtx( source ); + Client::Context srcCtx(txn, source); Collection* sourceColl = srcCtx.db()->getCollection( txn, source ); if ( !sourceColl ) { @@ -182,7 +182,7 @@ namespace mongo { } { - Client::Context ctx( target ); + Client::Context ctx(txn, target ); // Check if the target namespace exists and if dropTarget is true. // If target exists and dropTarget is not true, return false. @@ -245,7 +245,7 @@ namespace mongo { Collection* sourceColl = NULL; { - Client::Context srcCtx( source ); + Client::Context srcCtx(txn, source); sourceColl = srcCtx.db()->getCollection( txn, source ); sourceIt.reset( sourceColl->getIterator( DiskLoc(), false, CollectionScanParams::FORWARD ) ); } @@ -254,12 +254,12 @@ namespace mongo { while ( !sourceIt->isEOF() ) { BSONObj o; { - Client::Context srcCtx( source ); + Client::Context srcCtx(txn, source); o = sourceColl->docFor(sourceIt->getNext()); } // Insert and check return status of insert. { - Client::Context ctx( target ); + Client::Context ctx(txn, target ); if ( !targetColl ) targetColl = ctx.db()->getCollection( txn, target ); // No logOp necessary because the entire renameCollection command is one logOp. @@ -275,7 +275,7 @@ namespace mongo { // If inserts were unsuccessful, drop the target collection and return false. if ( !insertSuccessful ) { - Client::Context ctx( target ); + Client::Context ctx(txn, target ); Status s = ctx.db()->dropCollection( txn, target ); if ( !s.isOK() ) errmsg = s.toString(); @@ -287,7 +287,7 @@ namespace mongo { vector<BSONObj> copiedIndexes; bool indexSuccessful = true; { - Client::Context srcCtx( source ); + Client::Context srcCtx(txn, source); IndexCatalog::IndexIterator sourceIndIt = sourceColl->getIndexCatalog()->getIndexIterator( true ); @@ -313,7 +313,7 @@ namespace mongo { } { - Client::Context ctx( target ); + Client::Context ctx(txn, target ); if ( !targetColl ) targetColl = ctx.db()->getCollection( txn, target ); @@ -339,7 +339,7 @@ namespace mongo { // Drop the source collection. { - Client::Context srcCtx( source ); + Client::Context srcCtx(txn, source); Status s = srcCtx.db()->dropCollection( txn, source ); if ( !s.isOK() ) { errmsg = s.toString(); diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index 58d5e143a11..20175588afc 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -62,7 +62,7 @@ namespace mongo { BSONObj obj = cmdObj[ "obj" ].embeddedObjectUserCheck(); Lock::DBWrite lk(txn->lockState(), ns); - Client::Context ctx( ns ); + Client::Context ctx(txn, ns ); Database* db = ctx.db(); Collection* collection = db->getCollection( txn, ns ); if ( !collection ) { diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index 52acb7aae6f..39b5e7c0014 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -918,8 +918,9 @@ namespace mongo { if (!checkIndexConstraints(txn, &shardingState, *request, result)) { return false; } - _context.reset(new Client::Context(request->getNS(), - false /* don't check version */)); + + _context.reset(new Client::Context(txn, request->getNS(), false)); + Database* database = _context->db(); dassert(database); _collection = database->getCollection(txn, request->getTargetingNS()); @@ -1098,7 +1099,7 @@ namespace mongo { if (!checkShardVersion(txn, &shardingState, *updateItem.getRequest(), result)) return; - Client::Context ctx(nsString.ns(), false /* don't check version */); + Client::Context ctx(txn, nsString.ns(), false /* don't check version */); try { UpdateResult res = executor.execute(txn, ctx.db()); @@ -1159,8 +1160,7 @@ namespace mongo { // Context once we're locked, to set more details in currentOp() // TODO: better constructor? - Client::Context writeContext( nss.ns(), - false /* don't check version */); + Client::Context writeContext(txn, nss.ns(), false /* don't check version */); try { result->getStats().n = executor.execute(txn, writeContext.db()); |