summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-08-27 00:13:02 +0000
committerevergreen <evergreen@mongodb.com>2019-08-27 00:13:02 +0000
commit40f226b5a9bfb4863268334d287a46fb226a22cf (patch)
tree98b44b3a3bce352f30f0b05d264ab4e903b9aef9 /src/mongo/dbtests
parentdd2de577670e9461c31ca9e6fe5c9713b4401181 (diff)
downloadmongo-40f226b5a9bfb4863268334d287a46fb226a22cf.tar.gz
SERVER-33272 Proactively close newly empty databases
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/plan_executor_invalidation_test.cpp8
-rw-r--r--src/mongo/dbtests/rollbacktests.cpp8
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()));