summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/catalog/database.cpp4
-rw-r--r--src/mongo/dbtests/rollbacktests.cpp23
2 files changed, 19 insertions, 8 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index d966119efc7..f6b246395e6 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -561,12 +561,10 @@ Collection* Database::createCollection(OperationContext* txn,
_checkCanCreateCollection(nss, options);
audit::logCreateCollection(&cc(), ns);
- txn->recoveryUnit()->registerChange(new AddCollectionChange(txn, this, ns));
-
Status status = _dbEntry->createCollection(txn, ns, options, true /*allocateDefaultSpace*/);
massertNoTraceStatusOK(status);
-
+ txn->recoveryUnit()->registerChange(new AddCollectionChange(txn, this, ns));
Collection* collection = _getOrCreateCollectionInstance(txn, ns);
invariant(collection);
_collections[ns] = collection;
diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp
index 0986db98aa6..b842eb5a9bc 100644
--- a/src/mongo/dbtests/rollbacktests.cpp
+++ b/src/mongo/dbtests/rollbacktests.cpp
@@ -144,7 +144,7 @@ void dropIndex(OperationContext* txn, const NamespaceString& nss, const string&
}
} // namespace
-template <bool rollback, bool defaultIndexes>
+template <bool rollback, bool defaultIndexes, bool capped>
class CreateCollection {
public:
void run() {
@@ -160,7 +160,8 @@ public:
{
WriteUnitOfWork uow(&txn);
ASSERT(!collectionExists(&ctx, ns));
- ASSERT_OK(userCreateNS(&txn, ctx.db(), ns, BSONObj(), defaultIndexes));
+ auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj();
+ ASSERT_OK(userCreateNS(&txn, ctx.db(), ns, options, defaultIndexes));
ASSERT(collectionExists(&ctx, ns));
if (!rollback) {
uow.commit();
@@ -174,7 +175,7 @@ public:
}
};
-template <bool rollback, bool defaultIndexes>
+template <bool rollback, bool defaultIndexes, bool capped>
class DropCollection {
public:
void run() {
@@ -190,7 +191,8 @@ public:
{
WriteUnitOfWork uow(&txn);
ASSERT(!collectionExists(&ctx, ns));
- ASSERT_OK(userCreateNS(&txn, ctx.db(), ns, BSONObj(), defaultIndexes));
+ auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj();
+ ASSERT_OK(userCreateNS(&txn, ctx.db(), ns, options, defaultIndexes));
uow.commit();
}
ASSERT(collectionExists(&ctx, ns));
@@ -734,10 +736,21 @@ public:
template <template <bool, bool> class T>
void addAll() {
add<T<false, false>>();
- add<T<true, false>>();
add<T<false, true>>();
+ add<T<true, false>>();
add<T<true, true>>();
}
+ template <template <bool, bool, bool> class T>
+ void addAll() {
+ add<T<false, false, false>>();
+ add<T<false, false, true>>();
+ add<T<false, true, false>>();
+ add<T<false, true, true>>();
+ add<T<true, false, false>>();
+ add<T<true, false, true>>();
+ add<T<true, true, false>>();
+ add<T<true, true, true>>();
+ }
void setupTests() {
addAll<CreateCollection>();