diff options
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/plan_executor_invalidation_test.cpp | 8 | ||||
-rw-r--r-- | src/mongo/dbtests/rollbacktests.cpp | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/dbtests/plan_executor_invalidation_test.cpp b/src/mongo/dbtests/plan_executor_invalidation_test.cpp index 61eedeab72f..7a62f40afb8 100644 --- a/src/mongo/dbtests/plan_executor_invalidation_test.cpp +++ b/src/mongo/dbtests/plan_executor_invalidation_test.cpp @@ -59,6 +59,10 @@ static const NamespaceString nss("unittests.PlanExecutorInvalidationTest"); class PlanExecutorInvalidationTest : public unittest::Test { public: PlanExecutorInvalidationTest() : _client(&_opCtx) { + // Create an additional collection to prevent the database from closing when the other + // collection is dropped. + ASSERT_TRUE(_client.createCollection("unittests.PlanExecutorInvalidationTestUnused")); + _ctx.reset(new dbtests::WriteContextForTests(&_opCtx, nss.ns())); _client.dropCollection(nss.ns()); @@ -67,6 +71,10 @@ public: } } + ~PlanExecutorInvalidationTest() { + _client.dropCollection("unittests.PlanExecutorInvalidationTestUnused"); + } + /** * Return a plan executor that is going over the collection in nss.ns(). */ diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index fd48e6f46a3..d5e69fce2f3 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -53,7 +53,7 @@ namespace { const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2; void dropDatabase(OperationContext* opCtx, const NamespaceString& nss) { - Lock::GlobalWrite globalWriteLock(opCtx); + AutoGetDb autoDB(opCtx, nss.db(), MODE_X); auto databaseHolder = DatabaseHolder::get(opCtx); auto db = databaseHolder->getDb(opCtx, nss.db()); @@ -394,6 +394,12 @@ public: assertGet(CollectionOptions::parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); insertRecord(&opCtx, nss, oldDoc); + + // Create an additional collection to prevent the database from closing when the other + // collection is dropped. + NamespaceString unusedCollectionNSS("unittests.rollback_replace_collection_unused"); + ASSERT_OK(ctx.db()->userCreateNS( + &opCtx, unusedCollectionNSS, collectionOptions, defaultIndexes)); uow.commit(); } ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); |