From 97fbe83558a3d018b89eaff2d1ff74df1e67782d Mon Sep 17 00:00:00 2001 From: Xiangyu Yao Date: Wed, 1 Nov 2017 10:52:26 -0400 Subject: SERVER-31462 Register Database::AddCollectionChange in the correct order The wrong order leads to the rollback of CollectionImpl happening after the rollback of KVCollectionCatalogEntry. This means the Collection destructor would call setCappedCallback() on an already destroyed RecordStore. (cherry picked from commit f9e38f099a892964a09d4a80aafd8edfef21594d) --- src/mongo/dbtests/rollbacktests.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/mongo/dbtests/rollbacktests.cpp') diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index b842eb5a9bc..300d3f46aed 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -216,7 +216,7 @@ public: } }; -template +template class RenameCollection { public: void run() { @@ -236,7 +236,8 @@ public: WriteUnitOfWork uow(&txn); ASSERT(!collectionExists(&ctx, source.ns())); ASSERT(!collectionExists(&ctx, target.ns())); - ASSERT_OK(userCreateNS(&txn, ctx.db(), source.ns(), BSONObj(), defaultIndexes)); + auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); + ASSERT_OK(userCreateNS(&txn, ctx.db(), source.ns(), options, defaultIndexes)); uow.commit(); } ASSERT(collectionExists(&ctx, source.ns())); @@ -263,7 +264,7 @@ public: } }; -template +template class RenameDropTargetCollection { public: void run() { @@ -288,8 +289,9 @@ public: WriteUnitOfWork uow(&txn); ASSERT(!collectionExists(&ctx, source.ns())); ASSERT(!collectionExists(&ctx, target.ns())); - ASSERT_OK(userCreateNS(&txn, ctx.db(), source.ns(), BSONObj(), defaultIndexes)); - ASSERT_OK(userCreateNS(&txn, ctx.db(), target.ns(), BSONObj(), defaultIndexes)); + auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); + ASSERT_OK(userCreateNS(&txn, ctx.db(), source.ns(), options, defaultIndexes)); + ASSERT_OK(userCreateNS(&txn, ctx.db(), target.ns(), options, defaultIndexes)); insertRecord(&txn, source, sourceDoc); insertRecord(&txn, target, targetDoc); -- cgit v1.2.1