summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/storage_interface_impl.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2020-01-27 21:33:16 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-28 02:47:19 +0000
commitaea2622937550adae02f2e374398dca8cd5003dd (patch)
treeddbdbcb70e53f816e33b05a9fe060e46050131e3 /src/mongo/db/repl/storage_interface_impl.cpp
parent4fe19f8ab5388e61928fcf961502a45213445dd0 (diff)
downloadmongo-aea2622937550adae02f2e374398dca8cd5003dd.tar.gz
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
Diffstat (limited to 'src/mongo/db/repl/storage_interface_impl.cpp')
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp25
1 files changed, 11 insertions, 14 deletions
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<AutoGetCollection> 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<AutoGetCollection>(
+ 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<AutoGetCollection> autoColl = std::make_unique<AutoGetCollection>(
- 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<CollectionBulkLoaderImpl>(Client::releaseCurrent(),