From aea2622937550adae02f2e374398dca8cd5003dd Mon Sep 17 00:00:00 2001 From: Gregory Wlodarek Date: Mon, 27 Jan 2020 21:33:16 -0500 Subject: Revert "SERVER-39596 While a node is not in primary/secondary state, dbStats/collStats should not hang" This reverts commit 0e079cef6ba967a3cc930c6fb7960a9125a387ad. delete mode 100644 jstests/replsets/initial_sync_does_not_block_commands.js --- src/mongo/db/repl/storage_interface_impl.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/mongo/db/repl/storage_interface_impl.cpp') diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 531e10afaad..17af180cd45 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -217,29 +217,28 @@ StorageInterfaceImpl::createCollectionForBulkLoading( documentValidationDisabled(opCtx.get()) = true; + std::unique_ptr autoColl; // Retry if WCE. Status status = writeConflictRetry(opCtx.get(), "beginCollectionClone", nss.ns(), [&] { UnreplicatedWritesBlock uwb(opCtx.get()); // Get locks and create the collection. - AutoGetOrCreateDb autoDb(opCtx.get(), nss.db(), MODE_IX); - AutoGetCollection autoColl( - opCtx.get(), nss, fixLockModeForSystemDotViewsChanges(nss, MODE_X)); + AutoGetOrCreateDb db(opCtx.get(), nss.db(), MODE_IX); + AutoGetCollection coll(opCtx.get(), nss, fixLockModeForSystemDotViewsChanges(nss, MODE_X)); - if (autoColl.getCollection()) { + if (coll.getCollection()) { return Status(ErrorCodes::NamespaceExists, str::stream() << "Collection " << nss.ns() << " already exists."); } { // Create the collection. WriteUnitOfWork wunit(opCtx.get()); - fassert(40332, autoDb.getDb()->createCollection(opCtx.get(), nss, options, false)); + fassert(40332, db.getDb()->createCollection(opCtx.get(), nss, options, false)); wunit.commit(); } - Collection* coll = - CollectionCatalog::get(opCtx.get()).lookupCollectionByNamespace(opCtx.get(), nss); - invariant(coll); + autoColl = std::make_unique( + opCtx.get(), nss, fixLockModeForSystemDotViewsChanges(nss, MODE_IX)); // Build empty capped indexes. Capped indexes cannot be built by the MultiIndexBlock // because the cap might delete documents off the back while we are inserting them into @@ -248,14 +247,16 @@ StorageInterfaceImpl::createCollectionForBulkLoading( WriteUnitOfWork wunit(opCtx.get()); if (!idIndexSpec.isEmpty()) { auto status = - coll->getIndexCatalog()->createIndexOnEmptyCollection(opCtx.get(), idIndexSpec); + autoColl->getCollection()->getIndexCatalog()->createIndexOnEmptyCollection( + opCtx.get(), idIndexSpec); if (!status.getStatus().isOK()) { return status.getStatus(); } } for (auto&& spec : secondaryIndexSpecs) { auto status = - coll->getIndexCatalog()->createIndexOnEmptyCollection(opCtx.get(), spec); + autoColl->getCollection()->getIndexCatalog()->createIndexOnEmptyCollection( + opCtx.get(), spec); if (!status.getStatus().isOK()) { return status.getStatus(); } @@ -270,10 +271,6 @@ StorageInterfaceImpl::createCollectionForBulkLoading( return status; } - std::unique_ptr autoColl = std::make_unique( - opCtx.get(), nss, fixLockModeForSystemDotViewsChanges(nss, MODE_IX)); - invariant(autoColl->getCollection()); - // Move locks into loader, so it now controls their lifetime. auto loader = std::make_unique(Client::releaseCurrent(), -- cgit v1.2.1