From d3961a489a651d6e05d19fa20499a34a819a5088 Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Wed, 30 Apr 2014 15:20:51 -0400 Subject: SERVER-13797 Remove usages of Client::getContext() This change does not remove all usage of Client::getContext(), but only the simpler ones. --- src/mongo/db/catalog/index_catalog.cpp | 3 ++- src/mongo/db/db.cpp | 10 ---------- src/mongo/db/ops/delete_executor.cpp | 3 ++- src/mongo/db/query/cached_plan_runner.cpp | 11 +---------- src/mongo/db/query/multi_plan_runner.cpp | 12 ++---------- src/mongo/db/structure/btree/btree_logic.cpp | 21 +++++++++++---------- src/mongo/db/structure/btree/btree_logic.h | 5 ++++- src/mongo/db/structure/record_store_v1_simple.cpp | 3 ++- 8 files changed, 24 insertions(+), 44 deletions(-) (limited to 'src/mongo/db') diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 47ea2b82e11..5fd15c916b7 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -1205,7 +1205,8 @@ namespace mongo { if ( !status.isOK() ) { problem() << "Couldn't unindex record " << obj.toString() - << " status: " << status.toString(); + << " from collection " << _collection->ns() + << ". Status: " << status.toString(); } return Status::OK(); diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 00fb0cd9762..b36b9ce6914 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -124,14 +124,6 @@ namespace mongo { Timer startupSrandTimer; - const char *ourgetns() { - Client *c = currentClient.get(); - if ( ! c ) - return ""; - Client::Context* cc = c->getContext(); - return cc ? cc->ns() : ""; - } - struct MyStartupTests { MyStartupTests() { verify( sizeof(OID) == 12 ); @@ -968,8 +960,6 @@ static int mongoDbMain(int argc, char* argv[], char **envp) { mongo::reportEventToSystem = &mongo::reportEventToSystemImpl; #endif - getcurns = ourgetns; - setupSignalHandlers(); dbExecCommand = argv[0]; diff --git a/src/mongo/db/ops/delete_executor.cpp b/src/mongo/db/ops/delete_executor.cpp index 79d7a381434..248e240fd9f 100644 --- a/src/mongo/db/ops/delete_executor.cpp +++ b/src/mongo/db/ops/delete_executor.cpp @@ -171,7 +171,8 @@ namespace mongo { if (logop) { if ( toDelete.isEmpty() ) { - problem() << "deleted object without id, not logging" << endl; + problem() << "Deleted object without id in collection " << collection->ns() + << ", not logging."; } else { bool replJustOne = true; diff --git a/src/mongo/db/query/cached_plan_runner.cpp b/src/mongo/db/query/cached_plan_runner.cpp index 9b108cecb4b..6a17ffb4aa7 100644 --- a/src/mongo/db/query/cached_plan_runner.cpp +++ b/src/mongo/db/query/cached_plan_runner.cpp @@ -181,16 +181,7 @@ namespace mongo { return; } - // We need to check db and collection for NULL because updateCache() is called upon destruction of - // the CachedPlanRunner. In some cases, the db or collection could be dropped without kill() - // being called on the runner (for example, timeout of a ClientCursor holding the runner). - // XXX - this whole thing is odd - Database* db = cc().getContext()->db(); - if (NULL == db) { return; } - Collection* collection = db->getCollection(_canonicalQuery->ns()); - if (NULL == collection) { return; } - invariant( collection == _collection ); - PlanCache* cache = collection->infoCache()->getPlanCache(); + PlanCache* cache = _collection->infoCache()->getPlanCache(); std::auto_ptr feedback(new PlanCacheEntryFeedback()); feedback->stats.reset(_exec->getStats()); diff --git a/src/mongo/db/query/multi_plan_runner.cpp b/src/mongo/db/query/multi_plan_runner.cpp index 9fe4f28e04a..b544efa1e23 100644 --- a/src/mongo/db/query/multi_plan_runner.cpp +++ b/src/mongo/db/query/multi_plan_runner.cpp @@ -294,11 +294,7 @@ namespace mongo { // cached plan runner to fall back on a different solution // if the best solution fails. Alternatively we could try to // defer cache insertion to be after the first produced result. - Database* db = cc().getContext()->db(); - verify(NULL != db); - Collection* collection = db->getCollection(_query->ns()); - verify(NULL != collection); - PlanCache* cache = collection->infoCache()->getPlanCache(); + PlanCache* cache = _collection->infoCache()->getPlanCache(); cache->remove(*_query); // Move the backup info into the bestPlan info and clear the backup @@ -401,11 +397,7 @@ namespace mongo { const PlanStageStats* bestStats = _ranking->stats.vector()[0]; if (PlanCache::shouldCacheQuery(*_query) && (!_alreadyProduced.empty() || bestStats->common.isEOF)) { - Database* db = cc().getContext()->db(); - verify(NULL != db); - Collection* collection = db->getCollection(_query->ns()); - verify(NULL != collection); - PlanCache* cache = collection->infoCache()->getPlanCache(); + PlanCache* cache = _collection->infoCache()->getPlanCache(); // Create list of candidate solutions for the cache with // the best solution at the front. std::vector solutions; diff --git a/src/mongo/db/structure/btree/btree_logic.cpp b/src/mongo/db/structure/btree/btree_logic.cpp index 4032041798f..dfc1105f530 100644 --- a/src/mongo/db/structure/btree/btree_logic.cpp +++ b/src/mongo/db/structure/btree/btree_logic.cpp @@ -577,7 +577,7 @@ namespace mongo { invariant( foo >= 0 ); } setPacked(bucket); - assertValid(bucket, _ordering); + assertValid(_indexName, bucket, _ordering); } template @@ -1795,7 +1795,7 @@ namespace mongo { if (found) { BucketType* bucket = btreemod(trans, getBucket(loc)); delKeyAtPos(trans, bucket, loc, pos); - assertValid(getRoot(), _ordering); + assertValid(_indexName, getRoot(), _ordering); } return found; } @@ -1935,7 +1935,7 @@ namespace mongo { pushBack(r, kn.recordLoc, kn.data, kn.prevChildBucket); } r->nextChild = bucket->nextChild; - assertValid(r, _ordering); + assertValid(_indexName, r, _ordering); r = NULL; fixParentPtrs(trans, getBucket(rLoc), rLoc); @@ -1953,7 +1953,7 @@ namespace mongo { BucketType* p = btreemod(trans, getBucket(L)); pushBack(p, splitkey.recordLoc, splitkey.data, bucketLoc); p->nextChild = rLoc; - assertValid(p, _ordering); + assertValid(_indexName, p, _ordering); bucket->parent = L; _headManager->setHead(L); *trans->writing(&getBucket(rLoc)->parent) = bucket->parent; @@ -2084,7 +2084,7 @@ namespace mongo { bool dumpBuckets, unsigned depth) { BucketType* bucket = getBucket(bucketLoc); - assertValid(bucket, _ordering, true); + assertValid(_indexName, bucket, _ordering, true); if (dumpBuckets) { log() << bucketLoc.toString() << ' '; @@ -2138,9 +2138,10 @@ namespace mongo { // static template - void BtreeLogic::assertValid(BucketType* bucket, - const Ordering& ordering, - bool force) { + void BtreeLogic::assertValid(const std::string& ns, + BucketType* bucket, + const Ordering& ordering, + bool force) { if (!force) { return; } @@ -2190,7 +2191,7 @@ namespace mongo { int z = k1.data.woCompare(k2.data, ordering); //wassert( z <= 0 ); if (z > 0) { - problem() << "btree keys out of order" << '\n'; + problem() << "Btree keys out of order in collection " << ns; ONCE { dump(bucket); } @@ -2223,7 +2224,7 @@ namespace mongo { DiskLoc(), DiskLoc()); - assertValid(getRoot(), _ordering); + assertValid(_indexName, getRoot(), _ordering); return status; } diff --git a/src/mongo/db/structure/btree/btree_logic.h b/src/mongo/db/structure/btree/btree_logic.h index a003796f2fb..f15a41bb84c 100644 --- a/src/mongo/db/structure/btree/btree_logic.h +++ b/src/mongo/db/structure/btree/btree_logic.h @@ -293,7 +293,10 @@ namespace mongo { static void dump(BucketType* bucket, int depth = 0); - static void assertValid(BucketType* bucket, const Ordering& ordering, bool force = false); + static void assertValid(const std::string& ns, + BucketType* bucket, + const Ordering& ordering, + bool force = false); // // 'this'-specific helpers (require record store, catalog information, or ordering, or type diff --git a/src/mongo/db/structure/record_store_v1_simple.cpp b/src/mongo/db/structure/record_store_v1_simple.cpp index 85ec3bff441..f95e1c90f2b 100644 --- a/src/mongo/db/structure/record_store_v1_simple.cpp +++ b/src/mongo/db/structure/record_store_v1_simple.cpp @@ -100,7 +100,8 @@ namespace mongo { int fileOffset = cur.getOfs(); if (fileNumber < -1 || fileNumber >= 100000 || fileOffset < 0) { StringBuilder sb; - sb << "Deleted record list corrupted in bucket " << b + sb << "Deleted record list corrupted in collection " << _ns + << ", bucket " << b << ", link number " << chain << ", invalid link is " << cur.toString() << ", throwing Fatal Assertion"; -- cgit v1.2.1