diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-07-29 21:00:16 -0400 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-07-29 21:06:47 -0400 |
commit | 0d6d248c39a5b4e43eefc9320b5dec3229cfcfdb (patch) | |
tree | 1fb67633d3c9c551341dbf41efb47a80c6392553 /src/mongo/db/index_builder.cpp | |
parent | 47d0308cd596c6d40d6a3069379be1bdaf51d47b (diff) | |
download | mongo-0d6d248c39a5b4e43eefc9320b5dec3229cfcfdb.tar.gz |
SERVER-41696 Remove the 'ns' field from index specs
Diffstat (limited to 'src/mongo/db/index_builder.cpp')
-rw-r--r-- | src/mongo/db/index_builder.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index c741814a663..f7430beb84b 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -79,20 +79,11 @@ std::string IndexBuilder::name() const { return _name; } -Status IndexBuilder::buildInForeground(OperationContext* opCtx, Database* db) const { - return _buildAndHandleErrors(opCtx, db, false /*buildInBackground */, nullptr); -} - -Status IndexBuilder::_buildAndHandleErrors(OperationContext* opCtx, - Database* db, - bool buildInBackground, - Lock::DBLock* dbLock) const { - invariant(!buildInBackground); - invariant(!dbLock); +Status IndexBuilder::buildInForeground(OperationContext* opCtx, + Database* db, + Collection* coll) const { + invariant(opCtx->lockState()->isCollectionLockedForMode(coll->ns(), MODE_X)); - const NamespaceString ns(_index["ns"].String()); - - Collection* coll = db->getCollection(opCtx, ns); // Collections should not be implicitly created by the index builder. fassert(40409, coll); @@ -101,17 +92,12 @@ Status IndexBuilder::_buildAndHandleErrors(OperationContext* opCtx, // The 'indexer' can throw, so ensure build cleanup occurs. ON_BLOCK_EXIT([&] { indexer.cleanUpAfterBuild(opCtx, coll); }); - return _build(opCtx, buildInBackground, coll, indexer, dbLock); + return _build(opCtx, coll, indexer); } Status IndexBuilder::_build(OperationContext* opCtx, - bool buildInBackground, Collection* coll, - MultiIndexBlock& indexer, - Lock::DBLock* dbLock) const try { - invariant(!buildInBackground); - invariant(!dbLock); - + MultiIndexBlock& indexer) const try { auto ns = coll->ns(); { @@ -163,7 +149,6 @@ Status IndexBuilder::_build(OperationContext* opCtx, } { - Lock::CollectionLock collLock(opCtx, ns, MODE_IX); // WriteConflict exceptions and statuses are not expected to escape this method. status = indexer.insertAllDocumentsInCollection(opCtx, coll); if (!status.isOK()) { |