diff options
author | Maria van Keulen <maria@mongodb.com> | 2017-03-29 15:40:44 -0400 |
---|---|---|
committer | Maria van Keulen <maria@mongodb.com> | 2017-04-06 11:37:56 -0400 |
commit | 1cbb67b8acf6c579a8ef99f9b3bf74394bbd11c3 (patch) | |
tree | 426da6552cf3bb3315e46f925b0f3071e9979300 /src/mongo/dbtests | |
parent | 4516cbf1786f35557fe2f2e26e2e25373aa7af83 (diff) | |
download | mongo-1cbb67b8acf6c579a8ef99f9b3bf74394bbd11c3.tar.gz |
SERVER-28543 Add OperationContext as an argument to getCollection
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/counttests.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/dbtests.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/executor_registry.cpp | 11 | ||||
-rw-r--r-- | src/mongo/dbtests/namespacetests.cpp | 30 | ||||
-rw-r--r-- | src/mongo/dbtests/oplogstarttests.cpp | 4 | ||||
-rw-r--r-- | src/mongo/dbtests/pdfiletests.cpp | 5 | ||||
-rw-r--r-- | src/mongo/dbtests/query_plan_executor.cpp | 8 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_count_scan.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_fetch.cpp | 4 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_keep.cpp | 4 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_merge_sort.cpp | 20 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_sort.cpp | 12 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_update.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/querytests.cpp | 8 | ||||
-rw-r--r-- | src/mongo/dbtests/repltests.cpp | 10 | ||||
-rw-r--r-- | src/mongo/dbtests/rollbacktests.cpp | 26 |
16 files changed, 74 insertions, 76 deletions
diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp index 2ae6da87932..7fd12a2ce74 100644 --- a/src/mongo/dbtests/counttests.cpp +++ b/src/mongo/dbtests/counttests.cpp @@ -49,7 +49,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); - _collection = _database->getCollection(ns()); + _collection = _database->getCollection(&_opCtx, ns()); if (_collection) { _database->dropCollection(&_opCtx, ns()); } diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp index 2f54eb7d1ae..2ac3e5aa221 100644 --- a/src/mongo/dbtests/dbtests.cpp +++ b/src/mongo/dbtests/dbtests.cpp @@ -97,7 +97,7 @@ Status createIndexFromSpec(OperationContext* opCtx, StringData ns, const BSONObj Collection* coll; { WriteUnitOfWork wunit(opCtx); - coll = autoDb.getDb()->getOrCreateCollection(opCtx, ns); + coll = autoDb.getDb()->getOrCreateCollection(opCtx, NamespaceString(ns)); invariant(coll); wunit.commit(); } diff --git a/src/mongo/dbtests/executor_registry.cpp b/src/mongo/dbtests/executor_registry.cpp index c6fb21f1b1d..cfe2b68efb6 100644 --- a/src/mongo/dbtests/executor_registry.cpp +++ b/src/mongo/dbtests/executor_registry.cpp @@ -88,7 +88,7 @@ public: std::move(ws), std::move(scan), std::move(cq), - _ctx->db()->getCollection(nss.ns()), + _ctx->db()->getCollection(&_opCtx, nss), PlanExecutor::YIELD_MANUAL); ASSERT_OK(statusWithPlanExecutor.getStatus()); return statusWithPlanExecutor.getValue().release(); @@ -96,17 +96,14 @@ public: void registerExecutor(PlanExecutor* exec) { WriteUnitOfWork wuow(&_opCtx); - _ctx->db() - ->getOrCreateCollection(&_opCtx, nss.ns()) - ->getCursorManager() - ->registerExecutor(exec); + _ctx->db()->getOrCreateCollection(&_opCtx, nss)->getCursorManager()->registerExecutor(exec); wuow.commit(); } void deregisterExecutor(PlanExecutor* exec) { WriteUnitOfWork wuow(&_opCtx); _ctx->db() - ->getOrCreateCollection(&_opCtx, nss.ns()) + ->getOrCreateCollection(&_opCtx, nss) ->getCursorManager() ->deregisterExecutor(exec); wuow.commit(); @@ -117,7 +114,7 @@ public: } Collection* collection() { - return _ctx->db()->getCollection(nss.ns()); + return _ctx->db()->getCollection(&_opCtx, nss); } // Order of these is important for initialization diff --git a/src/mongo/dbtests/namespacetests.cpp b/src/mongo/dbtests/namespacetests.cpp index 5a861b35ae8..b853873a115 100644 --- a/src/mongo/dbtests/namespacetests.cpp +++ b/src/mongo/dbtests/namespacetests.cpp @@ -220,7 +220,7 @@ namespace NamespaceDetailsTests { return db()->getExtentManager(); } Collection* collection() const { - return db()->getCollection( ns() ); + return db()->getCollection( &opCtx, ns() ); } static BSONObj bigObj() { @@ -556,28 +556,28 @@ public: Collection* committedColl; { WriteUnitOfWork wunit(&opCtx); - ASSERT_FALSE(db->getCollection(committedName)); + ASSERT_FALSE(db->getCollection(&opCtx, committedName)); committedColl = db->createCollection(&opCtx, committedName); - ASSERT_EQUALS(db->getCollection(committedName), committedColl); + ASSERT_EQUALS(db->getCollection(&opCtx, committedName), committedColl); wunit.commit(); } - ASSERT_EQUALS(db->getCollection(committedName), committedColl); + ASSERT_EQUALS(db->getCollection(&opCtx, committedName), committedColl); { WriteUnitOfWork wunit(&opCtx); - ASSERT_FALSE(db->getCollection(rolledBackName)); + ASSERT_FALSE(db->getCollection(&opCtx, rolledBackName)); Collection* rolledBackColl = db->createCollection(&opCtx, rolledBackName); - ASSERT_EQUALS(db->getCollection(rolledBackName), rolledBackColl); + ASSERT_EQUALS(db->getCollection(&opCtx, rolledBackName), rolledBackColl); // not committing so creation should be rolled back } // The rolledBackCollection creation should have been rolled back - ASSERT_FALSE(db->getCollection(rolledBackName)); + ASSERT_FALSE(db->getCollection(&opCtx, rolledBackName)); // The committedCollection should not have been affected by the rollback. Holders // of the original Collection pointer should still be valid. - ASSERT_EQUALS(db->getCollection(committedName), committedColl); + ASSERT_EQUALS(db->getCollection(&opCtx, committedName), committedColl); } }; @@ -599,33 +599,33 @@ public: { WriteUnitOfWork wunit(&opCtx); - ASSERT_FALSE(db->getCollection(droppedName)); + ASSERT_FALSE(db->getCollection(&opCtx, droppedName)); Collection* droppedColl; droppedColl = db->createCollection(&opCtx, droppedName); - ASSERT_EQUALS(db->getCollection(droppedName), droppedColl); + ASSERT_EQUALS(db->getCollection(&opCtx, droppedName), droppedColl); db->dropCollection(&opCtx, droppedName); wunit.commit(); } // Should have been really dropped - ASSERT_FALSE(db->getCollection(droppedName)); + ASSERT_FALSE(db->getCollection(&opCtx, droppedName)); { WriteUnitOfWork wunit(&opCtx); - ASSERT_FALSE(db->getCollection(rolledBackName)); + ASSERT_FALSE(db->getCollection(&opCtx, rolledBackName)); Collection* rolledBackColl = db->createCollection(&opCtx, rolledBackName); wunit.commit(); - ASSERT_EQUALS(db->getCollection(rolledBackName), rolledBackColl); + ASSERT_EQUALS(db->getCollection(&opCtx, rolledBackName), rolledBackColl); db->dropCollection(&opCtx, rolledBackName); // not committing so dropping should be rolled back } // The rolledBackCollection dropping should have been rolled back. // Original Collection pointers are no longer valid. - ASSERT(db->getCollection(rolledBackName)); + ASSERT(db->getCollection(&opCtx, rolledBackName)); // The droppedCollection should not have been restored by the rollback. - ASSERT_FALSE(db->getCollection(droppedName)); + ASSERT_FALSE(db->getCollection(&opCtx, droppedName)); } }; } // namespace DatabaseTests diff --git a/src/mongo/dbtests/oplogstarttests.cpp b/src/mongo/dbtests/oplogstarttests.cpp index de5c365f421..d04754c65b8 100644 --- a/src/mongo/dbtests/oplogstarttests.cpp +++ b/src/mongo/dbtests/oplogstarttests.cpp @@ -45,7 +45,7 @@ static const NamespaceString nss("unittests.oplogstarttests"); class Base { public: Base() : _lk(&_opCtx), _context(&_opCtx, nss.ns()), _client(&_opCtx) { - Collection* c = _context.db()->getCollection(nss.ns()); + Collection* c = _context.db()->getCollection(&_opCtx, nss); if (!c) { WriteUnitOfWork wuow(&_opCtx); c = _context.db()->createCollection(&_opCtx, nss.ns()); @@ -63,7 +63,7 @@ public: protected: Collection* collection() { - return _context.db()->getCollection(nss.ns()); + return _context.db()->getCollection(&_opCtx, nss); } DBDirectClient* client() { diff --git a/src/mongo/dbtests/pdfiletests.cpp b/src/mongo/dbtests/pdfiletests.cpp index 65ed6a714cf..bbf98ca2cc6 100644 --- a/src/mongo/dbtests/pdfiletests.cpp +++ b/src/mongo/dbtests/pdfiletests.cpp @@ -59,7 +59,7 @@ protected: return "unittests.pdfiletests.Insert"; } Collection* collection() { - return _context.db()->getCollection(ns()); + return _context.db()->getCollection(&_opCtx, ns()); } const ServiceContext::UniqueOperationContext _opCtxPtr = cc().makeOperationContext(); @@ -74,7 +74,8 @@ public: WriteUnitOfWork wunit(&_opCtx); BSONObj x = BSON("x" << 1); ASSERT(x["_id"].type() == 0); - Collection* collection = _context.db()->getOrCreateCollection(&_opCtx, ns()); + Collection* collection = + _context.db()->getOrCreateCollection(&_opCtx, NamespaceString(ns())); OpDebug* const nullOpDebug = nullptr; ASSERT(!collection->insertDocument(&_opCtx, x, nullOpDebug, true).isOK()); diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp index 3b2ce822a45..7b4f372c5b0 100644 --- a/src/mongo/dbtests/query_plan_executor.cpp +++ b/src/mongo/dbtests/query_plan_executor.cpp @@ -147,7 +147,7 @@ public: ixparams.bounds.boundInclusion = BoundInclusion::kIncludeBothStartAndEndKeys; ixparams.direction = 1; - const Collection* coll = db->getCollection(nss.ns()); + const Collection* coll = db->getCollection(&_opCtx, nss); unique_ptr<WorkingSet> ws(new WorkingSet()); IndexScan* ix = new IndexScan(&_opCtx, ixparams, ws.get(), NULL); @@ -183,7 +183,7 @@ public: // TODO: This is not correct (create collection under S-lock) AutoGetCollectionForReadCommand ctx(&_opCtx, nss); WriteUnitOfWork wunit(&_opCtx); - Collection* collection = ctx.getDb()->getOrCreateCollection(&_opCtx, nss.ns()); + Collection* collection = ctx.getDb()->getOrCreateCollection(&_opCtx, nss); collection->getCursorManager()->registerExecutor(exec); wunit.commit(); } @@ -192,7 +192,7 @@ public: // TODO: This is not correct (create collection under S-lock) AutoGetCollectionForReadCommand ctx(&_opCtx, nss); WriteUnitOfWork wunit(&_opCtx); - Collection* collection = ctx.getDb()->getOrCreateCollection(&_opCtx, nss.ns()); + Collection* collection = ctx.getDb()->getOrCreateCollection(&_opCtx, nss); collection->getCursorManager()->deregisterExecutor(exec); wunit.commit(); } @@ -203,7 +203,7 @@ protected: private: IndexDescriptor* getIndex(Database* db, const BSONObj& obj) { - Collection* collection = db->getCollection(nss.ns()); + Collection* collection = db->getCollection(&_opCtx, nss); std::vector<IndexDescriptor*> indexes; collection->getIndexCatalog()->findIndexesByKeyPattern(&_opCtx, obj, false, &indexes); ASSERT_LTE(indexes.size(), 1U); diff --git a/src/mongo/dbtests/query_stage_count_scan.cpp b/src/mongo/dbtests/query_stage_count_scan.cpp index 87d2b87b283..c034b89b357 100644 --- a/src/mongo/dbtests/query_stage_count_scan.cpp +++ b/src/mongo/dbtests/query_stage_count_scan.cpp @@ -91,7 +91,7 @@ public: } IndexDescriptor* getIndex(Database* db, const BSONObj& obj) { - Collection* collection = db->getCollection(ns()); + Collection* collection = db->getCollection(&_opCtx, ns()); std::vector<IndexDescriptor*> indexes; collection->getIndexCatalog()->findIndexesByKeyPattern(&_opCtx, obj, false, &indexes); return indexes.empty() ? nullptr : indexes[0]; diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp index f44c03d7e26..ee8c5ec2b19 100644 --- a/src/mongo/dbtests/query_stage_fetch.cpp +++ b/src/mongo/dbtests/query_stage_fetch.cpp @@ -96,7 +96,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -161,7 +161,7 @@ public: Lock::DBLock lk(&_opCtx, nsToDatabaseSubstring(ns()), MODE_X); OldClientContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); diff --git a/src/mongo/dbtests/query_stage_keep.cpp b/src/mongo/dbtests/query_stage_keep.cpp index c5a57396987..06e5753f85e 100644 --- a/src/mongo/dbtests/query_stage_keep.cpp +++ b/src/mongo/dbtests/query_stage_keep.cpp @@ -113,7 +113,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -181,7 +181,7 @@ public: OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); diff --git a/src/mongo/dbtests/query_stage_merge_sort.cpp b/src/mongo/dbtests/query_stage_merge_sort.cpp index 7eb05f0efcc..238237617ca 100644 --- a/src/mongo/dbtests/query_stage_merge_sort.cpp +++ b/src/mongo/dbtests/query_stage_merge_sort.cpp @@ -122,7 +122,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -193,7 +193,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -263,7 +263,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -334,7 +334,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -406,7 +406,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -475,7 +475,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -534,7 +534,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -650,7 +650,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -747,7 +747,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -820,7 +820,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp index 1bc24a40290..ea5d4fb87f3 100644 --- a/src/mongo/dbtests/query_stage_sort.cpp +++ b/src/mongo/dbtests/query_stage_sort.cpp @@ -237,7 +237,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -259,7 +259,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -290,7 +290,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -315,7 +315,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -424,7 +424,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -523,7 +523,7 @@ public: void run() { OldClientWriteContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wuow(&_opCtx); coll = db->createCollection(&_opCtx, ns()); diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp index 3153037c9ed..429180205fc 100644 --- a/src/mongo/dbtests/query_stage_update.cpp +++ b/src/mongo/dbtests/query_stage_update.cpp @@ -261,7 +261,7 @@ public: OpDebug* opDebug = &curOp.debug(); UpdateDriver driver((UpdateDriver::Options())); Database* db = ctx.db(); - Collection* coll = db->getCollection(nss.ns()); + Collection* coll = db->getCollection(&_opCtx, nss); // Get the RecordIds that would be returned by an in-order scan. vector<RecordId> recordIds; diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index e68d41bfcd8..9a756d054d2 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -64,7 +64,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); _database = _context.db(); - _collection = _database->getCollection(ns()); + _collection = _database->getCollection(&_opCtx, ns()); if (_collection) { _database->dropCollection(&_opCtx, ns()); } @@ -191,7 +191,7 @@ public: { WriteUnitOfWork wunit(&_opCtx); Database* db = ctx.db(); - if (db->getCollection(ns())) { + if (db->getCollection(&_opCtx, ns())) { _collection = NULL; db->dropCollection(&_opCtx, ns()); } @@ -691,7 +691,7 @@ public: long long cursorId = c->getCursorId(); auto pinnedCursor = unittest::assertGet( - ctx.db()->getCollection(ns)->getCursorManager()->pinCursor(cursorId)); + ctx.db()->getCollection(&_opCtx, ns)->getCursorManager()->pinCursor(cursorId)); ASSERT_EQUALS(three.toULL(), pinnedCursor.getCursor()->getSlaveReadTill().asULL()); } }; @@ -1700,7 +1700,7 @@ public: { OldClientWriteContext ctx(&_opCtx, ns()); auto pinnedCursor = unittest::assertGet( - ctx.db()->getCollection(ns())->getCursorManager()->pinCursor(cursorId)); + ctx.db()->getCollection(&_opCtx, ns())->getCursorManager()->pinCursor(cursorId)); string expectedAssertion = str::stream() << "Cannot kill pinned cursor: " << cursorId; ASSERT_THROWS_WHAT(CursorManager::eraseCursorGlobal(&_opCtx, cursorId), MsgAssertionException, diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp index 637429b4921..d967bfdb9ff 100644 --- a/src/mongo/dbtests/repltests.cpp +++ b/src/mongo/dbtests/repltests.cpp @@ -93,7 +93,7 @@ public: OldClientWriteContext ctx(&_opCtx, ns()); WriteUnitOfWork wuow(&_opCtx); - Collection* c = ctx.db()->getCollection(ns()); + Collection* c = ctx.db()->getCollection(&_opCtx, ns()); if (!c) { c = ctx.db()->createCollection(&_opCtx, ns()); } @@ -148,7 +148,7 @@ protected: Lock::GlobalWrite lk(&_opCtx); OldClientContext ctx(&_opCtx, ns()); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { WriteUnitOfWork wunit(&_opCtx); coll = db->createCollection(&_opCtx, ns()); @@ -195,7 +195,7 @@ protected: OldClientContext ctx(&_opCtx, ns); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns); + Collection* coll = db->getCollection(&_opCtx, ns); if (!coll) { WriteUnitOfWork wunit(&_opCtx); coll = db->createCollection(&_opCtx, ns); @@ -214,7 +214,7 @@ protected: OldClientContext ctx(&_opCtx, ns); WriteUnitOfWork wunit(&_opCtx); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns); + Collection* coll = db->getCollection(&_opCtx, ns); if (!coll) { coll = db->createCollection(&_opCtx, ns); } @@ -227,7 +227,7 @@ protected: OldClientContext ctx(&_opCtx, ns()); WriteUnitOfWork wunit(&_opCtx); Database* db = ctx.db(); - Collection* coll = db->getCollection(ns()); + Collection* coll = db->getCollection(&_opCtx, ns()); if (!coll) { coll = db->createCollection(&_opCtx, ns()); } diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index 50a7440fdb8..71f1a89a8ff 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -84,17 +84,17 @@ Status renameCollection(OperationContext* opCtx, return db->renameCollection(opCtx, source.ns(), target.ns(), false); } Status truncateCollection(OperationContext* opCtx, const NamespaceString& nss) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); return coll->truncate(opCtx); } void insertRecord(OperationContext* opCtx, const NamespaceString& nss, const BSONObj& data) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); OpDebug* const nullOpDebug = nullptr; ASSERT_OK(coll->insertDocument(opCtx, data, nullOpDebug, false)); } void assertOnlyRecord(OperationContext* opCtx, const NamespaceString& nss, const BSONObj& data) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); auto cursor = coll->getCursor(opCtx); auto record = cursor->next(); @@ -104,15 +104,15 @@ void assertOnlyRecord(OperationContext* opCtx, const NamespaceString& nss, const ASSERT(!cursor->next()); } void assertEmpty(OperationContext* opCtx, const NamespaceString& nss) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); ASSERT(!coll->getCursor(opCtx)->next()); } bool indexExists(OperationContext* opCtx, const NamespaceString& nss, const string& idxName) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); return coll->getIndexCatalog()->findIndexByName(opCtx, idxName, true) != NULL; } bool indexReady(OperationContext* opCtx, const NamespaceString& nss, const string& idxName) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); return coll->getIndexCatalog()->findIndexByName(opCtx, idxName, false) != NULL; } size_t getNumIndexEntries(OperationContext* opCtx, @@ -120,7 +120,7 @@ size_t getNumIndexEntries(OperationContext* opCtx, const string& idxName) { size_t numEntries = 0; - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); IndexDescriptor* desc = catalog->findIndexByName(opCtx, idxName, false); @@ -136,7 +136,7 @@ size_t getNumIndexEntries(OperationContext* opCtx, } void dropIndex(OperationContext* opCtx, const NamespaceString& nss, const string& idxName) { - Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(nss.ns()); + Collection* coll = dbHolder().get(opCtx, nss.db())->getCollection(opCtx, nss); IndexDescriptor* desc = coll->getIndexCatalog()->findIndexByName(opCtx, idxName); ASSERT(desc); ASSERT_OK(coll->getIndexCatalog()->dropIndex(opCtx, desc)); @@ -506,7 +506,7 @@ public: AutoGetDb autoDb(&opCtx, nss.db(), MODE_X); - Collection* coll = autoDb.getDb()->getCollection(ns); + Collection* coll = autoDb.getDb()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); string idxName = "a"; @@ -547,7 +547,7 @@ public: AutoGetDb autoDb(&opCtx, nss.db(), MODE_X); - Collection* coll = autoDb.getDb()->getCollection(ns); + Collection* coll = autoDb.getDb()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); string idxName = "a"; @@ -600,7 +600,7 @@ public: AutoGetDb autoDb(&opCtx, nss.db(), MODE_X); - Collection* coll = autoDb.getDb()->getCollection(ns); + Collection* coll = autoDb.getDb()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); string idxName = "a"; @@ -644,7 +644,7 @@ public: AutoGetDb autoDb(&opCtx, nss.db(), MODE_X); - Collection* coll = autoDb.getDb()->getCollection(ns); + Collection* coll = autoDb.getDb()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); string idxName = "a"; @@ -725,7 +725,7 @@ public: ASSERT_OK(userCreateNS( &opCtx, ctx.db(), nss.ns(), BSONObj(), CollectionOptions::parseForCommand, false)); ASSERT(collectionExists(&ctx, nss.ns())); - Collection* coll = ctx.db()->getCollection(ns); + Collection* coll = ctx.db()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); ASSERT_OK(catalog->createIndexOnEmptyCollection(&opCtx, specA)); |