diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-04-25 14:52:27 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2019-04-25 14:54:20 -0400 |
commit | 62aa69d685e1b6cde2fd3ab826cf12d1f20221fd (patch) | |
tree | 3f07096bd5f5c7f5edde9a43a084400480a41431 /src/mongo/dbtests/rollbacktests.cpp | |
parent | 24d4a296aacf4acc981094f5cdf973ad62ab67fa (diff) | |
download | mongo-62aa69d685e1b6cde2fd3ab826cf12d1f20221fd.tar.gz |
Revert "SERVER-39520 Use database IX lock for dropCollection"
This reverts commit fdc3712e4cb89c23451061b4c927a78340269d89.
Diffstat (limited to 'src/mongo/dbtests/rollbacktests.cpp')
-rw-r--r-- | src/mongo/dbtests/rollbacktests.cpp | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index aa90d235361..d114992fb13 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -61,10 +61,10 @@ void dropDatabase(OperationContext* opCtx, const NamespaceString& nss) { databaseHolder->dropDb(opCtx, db); } } -bool collectionExists(OperationContext* opCtx, OldClientContext* ctx, const string& ns) { +bool collectionExists(OldClientContext* ctx, const string& ns) { auto nss = NamespaceString(ns); std::vector<NamespaceString> collections = - UUIDCatalog::get(getGlobalServiceContext()).getAllCollectionNamesFromDb(opCtx, nss.db()); + UUIDCatalog::get(getGlobalServiceContext()).getAllCollectionNamesFromDb(nss.db()); return std::count(collections.begin(), collections.end(), nss) > 0; } @@ -73,11 +73,11 @@ void createCollection(OperationContext* opCtx, const NamespaceString& nss) { OldClientContext ctx(opCtx, nss.ns()); { WriteUnitOfWork uow(opCtx); - ASSERT(!collectionExists(opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(opCtx, nss, collectionOptions, false)); - ASSERT(collectionExists(opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); uow.commit(); } } @@ -174,20 +174,20 @@ public: OldClientContext ctx(&opCtx, ns); { WriteUnitOfWork uow(&opCtx); - ASSERT(!collectionExists(&opCtx, &ctx, ns)); + ASSERT(!collectionExists(&ctx, ns)); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); - ASSERT(collectionExists(&opCtx, &ctx, ns)); + ASSERT(collectionExists(&ctx, ns)); if (!rollback) { uow.commit(); } } if (rollback) { - ASSERT(!collectionExists(&opCtx, &ctx, ns)); + ASSERT(!collectionExists(&ctx, ns)); } else { - ASSERT(collectionExists(&opCtx, &ctx, ns)); + ASSERT(collectionExists(&ctx, ns)); } } }; @@ -211,30 +211,30 @@ public: OldClientContext ctx(&opCtx, ns); { WriteUnitOfWork uow(&opCtx); - ASSERT(!collectionExists(&opCtx, &ctx, ns)); + ASSERT(!collectionExists(&ctx, ns)); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); uow.commit(); } - ASSERT(collectionExists(&opCtx, &ctx, ns)); + ASSERT(collectionExists(&ctx, ns)); // END OF SETUP / START OF TEST { WriteUnitOfWork uow(&opCtx); - ASSERT(collectionExists(&opCtx, &ctx, ns)); + ASSERT(collectionExists(&ctx, ns)); ASSERT_OK(ctx.db()->dropCollection(&opCtx, ns)); - ASSERT(!collectionExists(&opCtx, &ctx, ns)); + ASSERT(!collectionExists(&ctx, ns)); if (!rollback) { uow.commit(); } } if (rollback) { - ASSERT(collectionExists(&opCtx, &ctx, ns)); + ASSERT(collectionExists(&ctx, ns)); } else { - ASSERT(!collectionExists(&opCtx, &ctx, ns)); + ASSERT(!collectionExists(&ctx, ns)); } } }; @@ -261,34 +261,34 @@ public: { WriteUnitOfWork uow(&opCtx); - ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(!collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, source, collectionOptions, defaultIndexes)); uow.commit(); } - ASSERT(collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(!collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); // END OF SETUP / START OF TEST { WriteUnitOfWork uow(&opCtx); ASSERT_OK(renameCollection(&opCtx, source, target)); - ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); if (!rollback) { uow.commit(); } } if (rollback) { - ASSERT(collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(!collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); } else { - ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); } } }; @@ -320,8 +320,8 @@ public: { WriteUnitOfWork uow(&opCtx); - ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(!collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); auto options = capped ? BSON("capped" << true << "size" << 1000) : BSONObj(); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(options, CollectionOptions::parseForCommand)); @@ -334,8 +334,8 @@ public: uow.commit(); } - ASSERT(collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&opCtx, source, sourceDoc); assertOnlyRecord(&opCtx, target, targetDoc); @@ -351,21 +351,21 @@ public: {}, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); ASSERT_OK(renameCollection(&opCtx, source, target)); - ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&opCtx, target, sourceDoc); if (!rollback) { uow.commit(); } } if (rollback) { - ASSERT(collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&opCtx, source, sourceDoc); assertOnlyRecord(&opCtx, target, targetDoc); } else { - ASSERT(!collectionExists(&opCtx, &ctx, source.ns())); - ASSERT(collectionExists(&opCtx, &ctx, target.ns())); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&opCtx, target, sourceDoc); } } @@ -390,14 +390,14 @@ public: { WriteUnitOfWork uow(&opCtx); - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); insertRecord(&opCtx, nss, oldDoc); uow.commit(); } - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); assertOnlyRecord(&opCtx, nss, oldDoc); // END OF SETUP / START OF TEST @@ -411,18 +411,18 @@ public: result, {}, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, newDoc); assertOnlyRecord(&opCtx, nss, newDoc); if (!rollback) { uow.commit(); } } - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); if (rollback) { assertOnlyRecord(&opCtx, nss, oldDoc); } else { @@ -446,14 +446,14 @@ public: BSONObj doc = BSON("_id" << "example string"); - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); { WriteUnitOfWork uow(&opCtx); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, doc); assertOnlyRecord(&opCtx, nss, doc); @@ -464,13 +464,13 @@ public: result, {}, DropCollectionSystemCollectionMode::kDisallowSystemCollectionDrops)); - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); if (!rollback) { uow.commit(); } } - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); } }; @@ -489,14 +489,14 @@ public: BSONObj doc = BSON("_id" << "foo"); - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); { WriteUnitOfWork uow(&opCtx); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, defaultIndexes)); - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&opCtx, nss, doc); assertOnlyRecord(&opCtx, nss, doc); uow.commit(); @@ -509,14 +509,14 @@ public: WriteUnitOfWork uow(&opCtx); ASSERT_OK(truncateCollection(&opCtx, nss)); - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); assertEmpty(&opCtx, nss); if (!rollback) { uow.commit(); } } - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); if (rollback) { assertOnlyRecord(&opCtx, nss, doc); } else { @@ -753,11 +753,11 @@ public: { WriteUnitOfWork uow(&opCtx); - ASSERT(!collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(!collectionExists(&ctx, nss.ns())); CollectionOptions collectionOptions; ASSERT_OK(collectionOptions.parse(BSONObj(), CollectionOptions::parseForCommand)); ASSERT_OK(ctx.db()->userCreateNS(&opCtx, nss, collectionOptions, false)); - ASSERT(collectionExists(&opCtx, &ctx, nss.ns())); + ASSERT(collectionExists(&ctx, nss.ns())); Collection* coll = ctx.db()->getCollection(&opCtx, nss); IndexCatalog* catalog = coll->getIndexCatalog(); @@ -770,9 +770,9 @@ public: } } // uow if (rollback) { - ASSERT(!collectionExists(&opCtx, &ctx, ns)); + ASSERT(!collectionExists(&ctx, ns)); } else { - ASSERT(collectionExists(&opCtx, &ctx, ns)); + ASSERT(collectionExists(&ctx, ns)); ASSERT(indexReady(&opCtx, nss, idxNameA)); ASSERT(indexReady(&opCtx, nss, idxNameB)); ASSERT(indexReady(&opCtx, nss, idxNameC)); |