summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/SConscript4
-rw-r--r--src/mongo/db/catalog/SConscript38
-rw-r--r--src/mongo/db/catalog/collection.h10
-rw-r--r--src/mongo/db/catalog/collection_compact.cpp4
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp5
-rw-r--r--src/mongo/db/catalog/collection_impl.h2
-rw-r--r--src/mongo/db/catalog/collection_mock.h4
-rw-r--r--src/mongo/db/catalog/database_test.cpp4
-rw-r--r--src/mongo/db/catalog/index_catalog.h1
-rw-r--r--src/mongo/db/catalog/multi_index_block.h6
-rw-r--r--src/mongo/db/catalog/multi_index_block_impl.cpp10
-rw-r--r--src/mongo/db/catalog/multi_index_block_impl.h4
-rw-r--r--src/mongo/db/catalog/multi_index_block_test.cpp57
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp4
-rw-r--r--src/mongo/db/catalog/rename_collection_test.cpp4
-rw-r--r--src/mongo/db/cloner.cpp4
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/create_indexes.cpp4
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp3
-rw-r--r--src/mongo/db/index_builder.cpp5
-rw-r--r--src/mongo/db/index_rebuilder.cpp5
-rw-r--r--src/mongo/db/repair_database.cpp3
-rw-r--r--src/mongo/db/repl/SConscript3
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp7
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp4
-rw-r--r--src/mongo/db/repl/storage_interface_impl_test.cpp5
-rw-r--r--src/mongo/db/s/SConscript1
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp4
-rw-r--r--src/mongo/db/system_index.cpp4
-rw-r--r--src/mongo/dbtests/SConscript1
-rw-r--r--src/mongo/dbtests/dbtests.cpp4
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp13
-rw-r--r--src/mongo/dbtests/storage_timestamp_tests.cpp7
-rw-r--r--src/mongo/dbtests/wildcard_multikey_persistence_test.cpp5
34 files changed, 167 insertions, 73 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 298c0c9559e..44f61615274 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -754,6 +754,7 @@ env.Library(
LIBDEPS=[
'db_raii',
'catalog/index_key_validate',
+ 'catalog/multi_index_block',
'concurrency/write_conflict_exception',
],
)
@@ -865,6 +866,7 @@ env.Library(
'write_ops',
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/catalog/collection_options',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/auth/internal_user_auth',
@@ -894,6 +896,7 @@ env.Library(
'db_raii',
'index/index_access_methods',
'$BUILD_DIR/mongo/db/catalog/index_catalog',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
],
LIBDEPS_PRIVATE=[
"logical_clock",
@@ -960,6 +963,7 @@ env.Library(
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/catalog/document_validation',
'$BUILD_DIR/mongo/db/catalog/index_key_validate',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
'$BUILD_DIR/mongo/db/storage/storage_repair_observer',
'$BUILD_DIR/mongo/db/repl/oplog',
],
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index e0400100f20..30c58486dde 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -147,6 +147,7 @@ env.CppUnitTest(
],
LIBDEPS=[
'database',
+ 'multi_index_block',
'$BUILD_DIR/mongo/db/auth/authmocks',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
'$BUILD_DIR/mongo/db/db_raii',
@@ -181,6 +182,40 @@ env.Library(
)
env.Library(
+ target='multi_index_block',
+ source=[
+ 'multi_index_block_impl.cpp',
+ ],
+ LIBDEPS=[
+ 'collection',
+ 'collection_info_cache',
+ '$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/db/audit',
+ '$BUILD_DIR/mongo/db/background',
+ '$BUILD_DIR/mongo/db/concurrency/write_conflict_exception',
+ '$BUILD_DIR/mongo/db/curop',
+ '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
+ '$BUILD_DIR/mongo/db/server_parameters',
+ '$BUILD_DIR/mongo/db/service_context',
+ '$BUILD_DIR/mongo/db/storage/write_unit_of_work',
+ '$BUILD_DIR/mongo/util/fail_point',
+ '$BUILD_DIR/mongo/util/progress_meter',
+ ],
+)
+
+env.CppUnitTest(
+ target='multi_index_block_test',
+ source=[
+ 'multi_index_block_test.cpp'
+ ],
+ LIBDEPS=[
+ 'collection',
+ 'multi_index_block',
+ '$BUILD_DIR/mongo/db/namespace_string',
+ ],
+)
+
+env.Library(
target='uuid_catalog',
source=[
'namespace_uuid_cache.cpp',
@@ -241,7 +276,6 @@ env.Library(
"index_catalog_entry_impl.cpp",
"index_catalog_impl.cpp",
"index_consistency.cpp",
- "multi_index_block_impl.cpp",
"private/record_store_validate_adaptor.cpp",
],
LIBDEPS=[
@@ -307,6 +341,7 @@ env.Library(
'database',
'index_catalog',
'index_key_validate',
+ 'multi_index_block',
],
)
@@ -352,6 +387,7 @@ env.CppUnitTest(
],
LIBDEPS=[
'catalog_helpers',
+ 'multi_index_block',
'$BUILD_DIR/mongo/db/auth/authmocks',
'$BUILD_DIR/mongo/db/db_raii',
'$BUILD_DIR/mongo/db/namespace_string',
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index a53d560d4ad..79a987efdef 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -44,7 +44,6 @@
#include "mongo/db/catalog/collection_info_cache.h"
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/catalog/index_consistency.h"
-#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/cursor_manager.h"
#include "mongo/db/exec/collection_scan_common.h"
@@ -339,8 +338,6 @@ public:
OperationContext* opCtx,
PlanExecutor::YieldPolicy yieldPolicy,
ScanDirection scanDirection) = 0;
-
- virtual std::unique_ptr<MultiIndexBlock> createMultiIndexBlock(OperationContext* opCtx) = 0;
};
public:
@@ -737,13 +734,6 @@ public:
return this->_impl().makePlanExecutor(opCtx, yieldPolicy, scanDirection);
}
- /**
- * Creates an instance of MultiIndexBlock.
- */
- inline std::unique_ptr<MultiIndexBlock> createMultiIndexBlock(OperationContext* opCtx) {
- return this->_impl().createMultiIndexBlock(opCtx);
- }
-
private:
inline DatabaseCatalogEntry* dbce() const {
return this->_impl().dbce();
diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp
index 7390aaf9067..5cd68625468 100644
--- a/src/mongo/db/catalog/collection_compact.cpp
+++ b/src/mongo/db/catalog/collection_compact.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/index/index_access_method.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/operation_context.h"
@@ -125,8 +126,7 @@ StatusWith<CompactStats> compactCollection(OperationContext* opCtx,
CompactStats stats;
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
indexer.allowInterruption();
indexer.ignoreUniqueConstraint(); // in compact we should be doing no checking
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index f83e42931be..749ec31545b 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -49,7 +49,6 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_catalog_impl.h"
#include "mongo/db/catalog/index_consistency.h"
-#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/namespace_uuid_cache.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/clientcursor.h"
@@ -1304,10 +1303,6 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> CollectionImpl::makePlanExe
return InternalPlanner::collectionScan(opCtx, _ns.ns(), _this, yieldPolicy, direction);
}
-std::unique_ptr<MultiIndexBlock> CollectionImpl::createMultiIndexBlock(OperationContext* opCtx) {
- return std::make_unique<MultiIndexBlockImpl>(opCtx, _this);
-}
-
void CollectionImpl::setNs(NamespaceString nss) {
_ns = std::move(nss);
_indexCatalog->setNs(_ns);
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index 5e01c96ce93..69c768f4118 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -365,8 +365,6 @@ public:
PlanExecutor::YieldPolicy yieldPolicy,
ScanDirection scanDirection) final;
- std::unique_ptr<MultiIndexBlock> createMultiIndexBlock(OperationContext* opCtx) final;
-
private:
inline DatabaseCatalogEntry* dbce() const final {
return this->_dbce;
diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h
index 41f89f8bbb2..e8b4e0013f9 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -287,10 +287,6 @@ public:
std::abort();
}
- std::unique_ptr<MultiIndexBlock> createMultiIndexBlock(OperationContext* opCtx) {
- std::abort();
- }
-
OptionalCollectionUUID uuid() const {
std::abort();
}
diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp
index 6b560c05056..0fc1d321d38 100644
--- a/src/mongo/db/catalog/database_test.cpp
+++ b/src/mongo/db/catalog/database_test.cpp
@@ -35,6 +35,7 @@
#include "mongo/bson/util/builder.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
@@ -299,8 +300,7 @@ void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationCont
wuow.commit();
}
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
ON_BLOCK_EXIT([&indexer, opCtx] {
WriteUnitOfWork wuow(opCtx);
indexer.commit();
diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h
index 5186645ac32..73667f5fa36 100644
--- a/src/mongo/db/catalog/index_catalog.h
+++ b/src/mongo/db/catalog/index_catalog.h
@@ -67,7 +67,6 @@ struct BsonRecord {
*
* Index building functionality is supported by the IndexBuildBlockInterface interface. However, it
* is recommended to use the higher level MultiIndexBlock interface.
- * See Collection::createMultiIndexBlock().
*
* Due to the resource-intensive nature of the index building process, this interface also provides
* information on which indexes are available for queries through the following functions:
diff --git a/src/mongo/db/catalog/multi_index_block.h b/src/mongo/db/catalog/multi_index_block.h
index 73846898bdd..afa8723c043 100644
--- a/src/mongo/db/catalog/multi_index_block.h
+++ b/src/mongo/db/catalog/multi_index_block.h
@@ -142,7 +142,8 @@ public:
*
* Should not be called inside of a WriteUnitOfWork.
*/
- virtual Status doneInserting(std::set<RecordId>* const dupsOut = nullptr) = 0;
+ virtual Status doneInserting() = 0;
+ virtual Status doneInserting(std::set<RecordId>* const dupsOut) = 0;
/**
* Marks the index ready for use. Should only be called as the last method after
@@ -155,7 +156,8 @@ public:
*
* Requires holding an exclusive database lock.
*/
- virtual void commit(stdx::function<void(const BSONObj& spec)> onCreateFn = nullptr) = 0;
+ virtual void commit() = 0;
+ virtual void commit(stdx::function<void(const BSONObj& spec)> onCreateFn) = 0;
/**
* May be called at any time after construction but before a successful commit(). Suppresses
diff --git a/src/mongo/db/catalog/multi_index_block_impl.cpp b/src/mongo/db/catalog/multi_index_block_impl.cpp
index 46252ffa177..87a851f9c1d 100644
--- a/src/mongo/db/catalog/multi_index_block_impl.cpp
+++ b/src/mongo/db/catalog/multi_index_block_impl.cpp
@@ -430,7 +430,7 @@ Status MultiIndexBlockImpl::insertAllDocumentsInCollection() {
}
if (state != PlanExecutor::IS_EOF) {
- return WorkingSetCommon::getMemberObjectStatus(objToIndex.value());
+ return exec->getMemberObjectStatus(objToIndex.value());
}
if (MONGO_FAIL_POINT(hangAfterStartingIndexBuildUnlocked)) {
@@ -485,6 +485,10 @@ Status MultiIndexBlockImpl::insert(const BSONObj& doc, const RecordId& loc) {
return Status::OK();
}
+Status MultiIndexBlockImpl::doneInserting() {
+ return doneInserting(nullptr);
+}
+
Status MultiIndexBlockImpl::doneInserting(std::set<RecordId>* dupsOut) {
invariant(!_opCtx->lockState()->inAWriteUnitOfWork());
for (size_t i = 0; i < _indexes.size(); i++) {
@@ -510,6 +514,10 @@ void MultiIndexBlockImpl::abortWithoutCleanup() {
_needToCleanup = false;
}
+void MultiIndexBlockImpl::commit() {
+ commit({});
+}
+
void MultiIndexBlockImpl::commit(stdx::function<void(const BSONObj& spec)> onCreateFn) {
// Do not interfere with writing multikey information when committing index builds.
auto restartTracker =
diff --git a/src/mongo/db/catalog/multi_index_block_impl.h b/src/mongo/db/catalog/multi_index_block_impl.h
index 8b4e9813fdf..887d44d2ca3 100644
--- a/src/mongo/db/catalog/multi_index_block_impl.h
+++ b/src/mongo/db/catalog/multi_index_block_impl.h
@@ -155,7 +155,8 @@ public:
*
* Must not be called inside of a WriteUnitOfWork.
*/
- Status doneInserting(std::set<RecordId>* dupsOut = nullptr) override;
+ Status doneInserting() override;
+ Status doneInserting(std::set<RecordId>* dupsOut) override;
/**
* Marks the index ready for use. Should only be called as the last method after
@@ -166,6 +167,7 @@ public:
*
* Requires holding an exclusive database lock.
*/
+ void commit() override;
void commit(stdx::function<void(const BSONObj& spec)> onCreateFn) override;
/**
diff --git a/src/mongo/db/catalog/multi_index_block_test.cpp b/src/mongo/db/catalog/multi_index_block_test.cpp
new file mode 100644
index 00000000000..4f09562a847
--- /dev/null
+++ b/src/mongo/db/catalog/multi_index_block_test.cpp
@@ -0,0 +1,57 @@
+
+/**
+ * Copyright (C) 2018-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/db/catalog/multi_index_block.h"
+
+#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/collection_mock.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
+#include "mongo/db/operation_context_noop.h"
+#include "mongo/unittest/unittest.h"
+
+namespace mongo {
+namespace {
+
+/**
+ * Simple initialization test for MultiIndexBlock to check library dependencies.
+ * For greater test coverage, it may be necessary to make this test fixture inherit from
+ * ServiceContextMongoDTest.
+ */
+class MultiIndexBlockTest : public unittest::Test {};
+
+TEST_F(MultiIndexBlockTest, Create) {
+ OperationContextNoop opCtx;
+ NamespaceString nss("mydb.mycoll");
+ Collection collection(std::make_unique<CollectionMock>(nss));
+ MultiIndexBlockImpl(&opCtx, &collection);
+}
+
+} // namespace
+} // namespace mongo
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index 1ec4f33a7de..831839f5c8a 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/catalog/drop_collection.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -422,8 +423,7 @@ Status renameCollectionCommon(OperationContext* opCtx,
// Copy the index descriptions from the source collection, adjusting the ns field.
{
- auto indexerPtr = tmpColl->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, tmpColl);
indexer.allowInterruption();
std::vector<BSONObj> indexesToCopy;
diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp
index ddd0bdc85c4..30a87ef0261 100644
--- a/src/mongo/db/catalog/rename_collection_test.cpp
+++ b/src/mongo/db/catalog/rename_collection_test.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/rename_collection.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
@@ -416,8 +417,7 @@ void _createIndex(OperationContext* opCtx,
<< "ns"
<< nss.ns());
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
ASSERT_OK(indexer.init(indexInfoObj).getStatus());
WriteUnitOfWork wuow(opCtx);
indexer.commit();
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index e30776227d3..1fbc4699d72 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/list_collections_filter.h"
#include "mongo/db/commands/rename_collection.h"
@@ -392,8 +393,7 @@ void Cloner::copyIndexes(OperationContext* opCtx,
// from creation to completion without yielding to ensure the index and the collection
// matches. It also wouldn't work on non-empty collections so we would need both
// implementations anyway as long as that is supported.
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
indexer.allowInterruption();
indexer.removeExistingIndexes(&indexesToBuild);
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 8cfc52999db..c1113f28795 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -250,6 +250,7 @@ env.Library(
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/catalog/catalog_helpers',
'$BUILD_DIR/mongo/db/catalog/index_key_validate',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
'$BUILD_DIR/mongo/db/command_can_run_here',
'$BUILD_DIR/mongo/db/commands',
'$BUILD_DIR/mongo/db/curop_failpoint_helpers',
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 1a5df96451f..4b7cbfef7dd 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/command_generic_argument.h"
#include "mongo/db/commands.h"
@@ -353,8 +354,7 @@ public:
statsTracker.emplace(opCtx, ns, Top::LockType::WriteLocked, dbProfilingLevel);
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
indexer.allowBackgroundBuilding();
indexer.allowInterruption();
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index f1b2e1a3fc7..b76d01f3b28 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -202,7 +203,7 @@ public:
WriteUnitOfWork wunit(opCtx);
collection->getIndexCatalog()->dropAllIndexes(opCtx, true);
- indexer = collection->createMultiIndexBlock(opCtx);
+ indexer = std::make_unique<MultiIndexBlockImpl>(opCtx, collection);
swIndexesToRebuild = indexer->init(all);
uassertStatusOK(swIndexesToRebuild.getStatus());
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index 8df84e6dadb..a95b20674f7 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -37,7 +37,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
-#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
@@ -197,8 +197,7 @@ Status IndexBuilder::_build(OperationContext* opCtx,
CurOp::get(opCtx)->setOpDescription_inlock(_index);
}
- auto indexerPtr = coll->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, coll);
indexer.allowInterruption();
if (allowBackgroundBuilding)
indexer.allowBackgroundBuilding();
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
index 14cf4cb0af8..e3cd2013df5 100644
--- a/src/mongo/db/index_rebuilder.cpp
+++ b/src/mongo/db/index_rebuilder.cpp
@@ -42,7 +42,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_catalog_entry.h"
-#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/service_context.h"
@@ -82,8 +82,7 @@ void checkNS(OperationContext* opCtx, const std::list<std::string>& nsToCheck) {
}
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
{
WriteUnitOfWork wunit(opCtx);
diff --git a/src/mongo/db/repair_database.cpp b/src/mongo/db/repair_database.cpp
index c8ac08cf4ae..8958fdaa525 100644
--- a/src/mongo/db/repair_database.cpp
+++ b/src/mongo/db/repair_database.cpp
@@ -49,6 +49,7 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/namespace_uuid_cache.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -147,7 +148,7 @@ Status rebuildIndexesOnCollection(OperationContext* opCtx,
const auto uuid = cce->getCollectionOptions(opCtx).uuid;
collection.reset(new Collection(opCtx, ns, uuid, cce, dbce->getRecordStore(ns), dbce));
- indexer = collection->createMultiIndexBlock(opCtx);
+ indexer = std::make_unique<MultiIndexBlockImpl>(opCtx, collection.get());
Status status = indexer->init(indexSpecs).getStatus();
if (!status.isOK()) {
// The WUOW will handle cleanup, so the indexer shouldn't do its own.
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 7508f0d75f2..d6ed23e4503 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -257,6 +257,7 @@ env.Library(
'rollback_idl',
'storage_interface',
'$BUILD_DIR/mongo/db/catalog/catalog_helpers',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/dbhelpers',
'$BUILD_DIR/mongo/db/query_exec',
@@ -276,6 +277,7 @@ env.CppUnitTest(
'replmocks',
'storage_interface_impl',
'$BUILD_DIR/mongo/db/auth/authmocks',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
'$BUILD_DIR/mongo/db/service_context_d_test_fixture',
],
)
@@ -585,6 +587,7 @@ env.CppUnitTest(
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/auth/authmocks',
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
'oplog_interface_local',
'rollback_test_fixture',
'rs_rollback',
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index d2b28d1d349..54b073f290a 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -38,6 +38,7 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -61,8 +62,10 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(ServiceContext::UniqueClient&
_opCtx{std::move(opCtx)},
_autoColl{std::move(autoColl)},
_nss{_autoColl->getCollection()->ns()},
- _idIndexBlock(_autoColl->getCollection()->createMultiIndexBlock(_opCtx.get())),
- _secondaryIndexesBlock(_autoColl->getCollection()->createMultiIndexBlock(_opCtx.get())),
+ _idIndexBlock(
+ std::make_unique<MultiIndexBlockImpl>(_opCtx.get(), _autoColl->getCollection())),
+ _secondaryIndexesBlock(
+ std::make_unique<MultiIndexBlockImpl>(_opCtx.get(), _autoColl->getCollection())),
_idIndexSpec(idIndexSpec.getOwned()) {
invariant(_opCtx);
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index 4bd27255559..ea8b0d1bbb6 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
@@ -176,8 +177,7 @@ int createIndexForColl(OperationContext* opCtx,
NamespaceString nss,
BSONObj indexSpec) {
Lock::DBLock dbLock(opCtx, nss.db(), MODE_X);
- auto indexerPtr = coll->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, coll);
ASSERT_OK(indexer.init(indexSpec).getStatus());
WriteUnitOfWork wunit(opCtx);
indexer.commit();
diff --git a/src/mongo/db/repl/storage_interface_impl_test.cpp b/src/mongo/db/repl/storage_interface_impl_test.cpp
index a1699986747..0913f0a1c56 100644
--- a/src/mongo/db/repl/storage_interface_impl_test.cpp
+++ b/src/mongo/db/repl/storage_interface_impl_test.cpp
@@ -39,6 +39,8 @@
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/document_validation.h"
+#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -136,8 +138,7 @@ int createIndexForColl(OperationContext* opCtx, NamespaceString nss, BSONObj ind
AutoGetCollection autoColl(opCtx, nss, MODE_X);
auto coll = autoColl.getCollection();
- auto indexerPtr = coll->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, coll);
ASSERT_OK(indexer.init(indexSpec).getStatus());
WriteUnitOfWork wunit(opCtx);
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 8583886b96d..38277dd005f 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -66,6 +66,7 @@ env.Library(
'split_vector.cpp',
],
LIBDEPS=[
+ '$BUILD_DIR/mongo/db/catalog/multi_index_block',
'$BUILD_DIR/mongo/db/commands/mongod_fcv',
'$BUILD_DIR/mongo/db/db_raii',
'$BUILD_DIR/mongo/db/dbhelpers',
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index 0eea65cafb1..c44e1fc4064 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/namespace_string.h"
@@ -635,8 +636,7 @@ void MigrationDestinationManager::cloneCollectionIndexesAndOptions(OperationCont
collection = db->getCollection(opCtx, nss);
}
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
indexer.removeExistingIndexes(&donorIndexSpecs);
if (!donorIndexSpecs.empty()) {
diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp
index 7caa6373c07..34ac8eca3a6 100644
--- a/src/mongo/db/system_index.cpp
+++ b/src/mongo/db/system_index.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
@@ -124,8 +125,7 @@ void generateSystemIndexForExistingCollection(OperationContext* opCtx,
log() << "No authorization index detected on " << ns
<< " collection. Attempting to recover by creating an index with spec: " << indexSpec;
- auto indexerPtr = collection->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, collection);
writeConflictRetry(opCtx, "authorization index regeneration", ns.ns(), [&] {
fassert(40453, indexer.init(indexSpec));
diff --git a/src/mongo/dbtests/SConscript b/src/mongo/dbtests/SConscript
index 61fd4c1b8a6..60f08f368e4 100644
--- a/src/mongo/dbtests/SConscript
+++ b/src/mongo/dbtests/SConscript
@@ -115,6 +115,7 @@ dbtest = env.Program(
"$BUILD_DIR/mongo/bson/mutable/mutable_bson_test_utils",
"$BUILD_DIR/mongo/db/auth/authmongod",
"$BUILD_DIR/mongo/db/bson/dotted_path_support",
+ "$BUILD_DIR/mongo/db/catalog/multi_index_block",
"$BUILD_DIR/mongo/db/commands/mongod",
"$BUILD_DIR/mongo/db/commands/test_commands_enabled",
"$BUILD_DIR/mongo/db/concurrency/deferred_writer",
diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp
index b02cab2ca19..38a422bf936 100644
--- a/src/mongo/dbtests/dbtests.cpp
+++ b/src/mongo/dbtests/dbtests.cpp
@@ -39,6 +39,7 @@
#include "mongo/base/initializer.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/db_raii.h"
@@ -104,8 +105,7 @@ Status createIndexFromSpec(OperationContext* opCtx, StringData ns, const BSONObj
invariant(coll);
wunit.commit();
}
- auto indexerPtr = coll->createMultiIndexBlock(opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx, coll);
Status status = indexer.init(spec).getStatus();
if (status == ErrorCodes::IndexAlreadyExists) {
return Status::OK();
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index de468427c54..c3d5a62607b 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/client.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
@@ -76,8 +77,7 @@ protected:
bool buildIndexInterrupted(const BSONObj& key, bool allowInterruption) {
try {
- auto indexerPtr = collection()->createMultiIndexBlock(&_opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(&_opCtx, collection());
if (allowInterruption)
indexer.allowInterruption();
@@ -130,8 +130,7 @@ public:
wunit.commit();
}
- auto indexerPtr = coll->createMultiIndexBlock(&_opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(&_opCtx, coll);
indexer.allowBackgroundBuilding();
indexer.allowInterruption();
indexer.ignoreUniqueConstraint();
@@ -187,8 +186,7 @@ public:
wunit.commit();
}
- auto indexerPtr = coll->createMultiIndexBlock(&_opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(&_opCtx, coll);
indexer.allowBackgroundBuilding();
indexer.allowInterruption();
// indexer.ignoreUniqueConstraint(); // not calling this
@@ -374,8 +372,7 @@ public:
};
Status IndexBuildBase::createIndex(const std::string& dbname, const BSONObj& indexSpec) {
- auto indexerPtr = collection()->createMultiIndexBlock(&_opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(&_opCtx, collection());
Status status = indexer.init(indexSpec).getStatus();
if (status == ErrorCodes::IndexAlreadyExists) {
return Status::OK();
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp
index 9043da447ee..8d37d785544 100644
--- a/src/mongo/dbtests/storage_timestamp_tests.cpp
+++ b/src/mongo/dbtests/storage_timestamp_tests.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -231,8 +232,7 @@ public:
void createIndex(Collection* coll, std::string indexName, const BSONObj& indexKey) {
// Build an index.
- auto indexerPtr = coll->createMultiIndexBlock(_opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(_opCtx, coll);
BSONObj indexInfoObj;
{
auto swIndexInfoObj = indexer.init({BSON(
@@ -1799,8 +1799,7 @@ public:
std::vector<std::string> origIdents = kvCatalog->getAllIdents(_opCtx);
// Build an index on `{a: 1}`. This index will be multikey.
- auto indexerPtr = autoColl.getCollection()->createMultiIndexBlock(_opCtx);
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(_opCtx, autoColl.getCollection());
const LogicalTime beforeIndexBuild = _clock->reserveTicks(2);
BSONObj indexInfoObj;
{
diff --git a/src/mongo/dbtests/wildcard_multikey_persistence_test.cpp b/src/mongo/dbtests/wildcard_multikey_persistence_test.cpp
index b5c2258d03c..e7b48c4f98e 100644
--- a/src/mongo/dbtests/wildcard_multikey_persistence_test.cpp
+++ b/src/mongo/dbtests/wildcard_multikey_persistence_test.cpp
@@ -32,6 +32,8 @@
#include <memory>
+#include "mongo/db/catalog/multi_index_block.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/repl/storage_interface_impl.h"
#include "mongo/unittest/unittest.h"
@@ -190,8 +192,7 @@ protected:
AutoGetCollection autoColl(opCtx(), nss, MODE_X);
auto coll = autoColl.getCollection();
- auto indexerPtr = coll->createMultiIndexBlock(opCtx());
- MultiIndexBlock& indexer(*indexerPtr);
+ MultiIndexBlockImpl indexer(opCtx(), coll);
indexer.allowBackgroundBuilding();
indexer.allowInterruption();