summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-10-12 09:37:57 -0400
committerBenety Goh <benety@mongodb.com>2018-10-12 09:37:57 -0400
commit65eced031a2c8d8b1c5e5815881466b8fbb3bc01 (patch)
tree7b44213a602fb20a72e63b56c84c342f71b2da52 /src/mongo/db
parentae2b60fce624cd9f4a95037316033b53846be176 (diff)
downloadmongo-65eced031a2c8d8b1c5e5815881466b8fbb3bc01.tar.gz
SERVER-36889 unshim MultiIndexBlock
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/SConscript4
-rw-r--r--src/mongo/db/catalog/SConscript16
-rw-r--r--src/mongo/db/catalog/collection.cpp1
-rw-r--r--src/mongo/db/catalog/collection.h11
-rw-r--r--src/mongo/db/catalog/collection_compact.cpp5
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp7
-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.cpp5
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp2
-rw-r--r--src/mongo/db/catalog/index_create.cpp62
-rw-r--r--src/mongo/db/catalog/multi_index_block.h (renamed from src/mongo/db/catalog/index_create.h)119
-rw-r--r--src/mongo/db/catalog/multi_index_block_impl.cpp (renamed from src/mongo/db/catalog/index_create_impl.cpp)8
-rw-r--r--src/mongo/db/catalog/multi_index_block_impl.h (renamed from src/mongo/db/catalog/index_create_impl.h)4
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp5
-rw-r--r--src/mongo/db/catalog/rename_collection_test.cpp5
-rw-r--r--src/mongo/db/cloner.cpp5
-rw-r--r--src/mongo/db/commands/create_indexes.cpp5
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp4
-rw-r--r--src/mongo/db/commands/rename_collection_cmd.cpp2
-rw-r--r--src/mongo/db/dbhelpers.cpp1
-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.cpp4
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp7
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.h2
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp5
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp1
-rw-r--r--src/mongo/db/repl/storage_interface_impl.h1
-rw-r--r--src/mongo/db/repl/storage_interface_impl_test.cpp3
-rw-r--r--src/mongo/db/s/SConscript1
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp5
-rw-r--r--src/mongo/db/system_index.cpp5
33 files changed, 85 insertions, 236 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 0f78df550db..079ac5467ad 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -753,7 +753,6 @@ env.Library(
],
LIBDEPS=[
'db_raii',
- 'catalog/index_create',
'catalog/index_key_validate',
'concurrency/write_conflict_exception',
],
@@ -866,7 +865,6 @@ env.Library(
'write_ops',
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/catalog/collection_options',
- '$BUILD_DIR/mongo/db/catalog/index_create',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/auth/internal_user_auth',
@@ -896,7 +894,6 @@ env.Library(
'db_raii',
'index/index_access_methods',
'$BUILD_DIR/mongo/db/catalog/index_catalog',
- '$BUILD_DIR/mongo/db/catalog/index_create',
],
LIBDEPS_PRIVATE=[
"logical_clock",
@@ -962,7 +959,6 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/db/catalog/document_validation',
- '$BUILD_DIR/mongo/db/catalog/index_create',
'$BUILD_DIR/mongo/db/catalog/index_key_validate',
'$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 a57ce8981f1..42c07b8995d 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -147,7 +147,6 @@ env.CppUnitTest(
],
LIBDEPS=[
'database',
- 'index_create',
'$BUILD_DIR/mongo/db/auth/authmocks',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
'$BUILD_DIR/mongo/db/db_raii',
@@ -182,16 +181,6 @@ env.Library(
)
env.Library(
- target='index_create',
- source=[
- 'index_create.cpp',
- ],
- LIBDEPS=[
- '$BUILD_DIR/mongo/base',
- ],
-)
-
-env.Library(
target='uuid_catalog',
source=[
'namespace_uuid_cache.cpp',
@@ -253,7 +242,7 @@ env.Library(
"index_catalog_entry_impl.cpp",
"index_catalog_impl.cpp",
"index_consistency.cpp",
- "index_create_impl.cpp",
+ "multi_index_block_impl.cpp",
"private/record_store_validate_adaptor.cpp",
],
LIBDEPS=[
@@ -265,7 +254,6 @@ env.Library(
'health_log',
'index_catalog',
'index_catalog_entry',
- 'index_create',
'index_key_validate',
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/background',
@@ -318,7 +306,6 @@ env.Library(
'collection',
'database',
'index_catalog',
- 'index_create',
],
)
@@ -364,7 +351,6 @@ env.CppUnitTest(
],
LIBDEPS=[
'catalog_helpers',
- 'index_create',
'$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.cpp b/src/mongo/db/catalog/collection.cpp
index 474992997a9..e3193081740 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/concurrency/d_concurrency.h"
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index ce77483315c..68a7ed95a2f 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -32,6 +32,7 @@
#include <memory>
#include <string>
+#include "mongo/base/shim.h"
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/base/string_data.h"
@@ -41,6 +42,7 @@
#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"
@@ -64,7 +66,6 @@ class IndexCatalog;
class IndexDescriptor;
class DatabaseImpl;
class MatchExpression;
-class MultiIndexBlock;
class OpDebug;
class OperationContext;
class RecordCursor;
@@ -339,6 +340,8 @@ public:
virtual void notifyCappedWaitersIfNeeded() = 0;
virtual const CollatorInterface* getDefaultCollator() const = 0;
+
+ virtual std::unique_ptr<MultiIndexBlock> createMultiIndexBlock(OperationContext* opCtx) = 0;
};
public:
@@ -724,6 +727,12 @@ public:
return this->_impl().getDefaultCollator();
}
+ /**
+ * Creates an instance of MultiIndexBlock.
+ */
+ inline std::unique_ptr<MultiIndexBlock> createMultiIndexBlock(OperationContext* opCtx) {
+ return this->_impl().createMultiIndexBlock(opCtx);
+ }
private:
inline DatabaseCatalogEntry* dbce() const {
diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp
index 1ecb601321b..bde69c3aaf5 100644
--- a/src/mongo/db/catalog/collection_compact.cpp
+++ b/src/mongo/db/catalog/collection_compact.cpp
@@ -34,8 +34,8 @@
#include "mongo/base/owned_pointer_map.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands/server_status.h"
#include "mongo/db/curop.h"
@@ -153,7 +153,8 @@ StatusWith<CompactStats> CollectionImpl::compact(OperationContext* opCtx,
CompactStats stats;
- MultiIndexBlock indexer(opCtx, _this);
+ auto indexerPtr = createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
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 e083e6a75c9..4f07cc381bd 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -47,7 +47,7 @@
#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/index_create.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"
@@ -1286,4 +1286,9 @@ Status CollectionImpl::touch(OperationContext* opCtx,
return Status::OK();
}
+
+std::unique_ptr<MultiIndexBlock> CollectionImpl::createMultiIndexBlock(OperationContext* opCtx) {
+ return std::make_unique<MultiIndexBlockImpl>(opCtx, _this);
+}
+
} // namespace mongo
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index 2cc8d32eda5..ee968da7550 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -356,6 +356,8 @@ public:
*/
const CollatorInterface* getDefaultCollator() const 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 a7eb21154a1..cab97a1ad91 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -276,6 +276,10 @@ 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 a64e61b12c8..203ff796ea1 100644
--- a/src/mongo/db/catalog/database_test.cpp
+++ b/src/mongo/db/catalog/database_test.cpp
@@ -32,7 +32,7 @@
#include "mongo/bson/util/builder.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
@@ -297,7 +297,8 @@ void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationCont
wuow.commit();
}
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
ON_BLOCK_EXIT([&indexer, opCtx] {
WriteUnitOfWork wuow(opCtx);
indexer.commit();
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 3539a9d08b0..9c81505c0be 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -43,8 +43,8 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/catalog/index_catalog_entry_impl.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/curop.h"
diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp
deleted file mode 100644
index 650dd5f576f..00000000000
--- a/src/mongo/db/catalog/index_create.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (C) 2017 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * 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 GNU Affero General 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.
- */
-
-#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kIndex
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/db/catalog/index_create.h"
-
-#include "mongo/base/error_codes.h"
-#include "mongo/db/audit.h"
-#include "mongo/db/background.h"
-#include "mongo/db/catalog/collection.h"
-#include "mongo/db/client.h"
-#include "mongo/db/clientcursor.h"
-#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/curop.h"
-#include "mongo/db/exec/working_set_common.h"
-#include "mongo/db/operation_context.h"
-#include "mongo/db/query/internal_plans.h"
-#include "mongo/db/server_parameters.h"
-#include "mongo/stdx/functional.h"
-#include "mongo/stdx/mutex.h"
-#include "mongo/util/fail_point.h"
-#include "mongo/util/fail_point_service.h"
-#include "mongo/util/log.h"
-#include "mongo/util/processinfo.h"
-#include "mongo/util/progress_meter.h"
-#include "mongo/util/quick_exit.h"
-
-namespace mongo {
-MultiIndexBlock::Impl::~Impl() = default;
-
-MONGO_DEFINE_SHIM(MultiIndexBlock::makeImpl);
-
-void MultiIndexBlock::TUHook::hook() noexcept {}
-} // namespace mongo
diff --git a/src/mongo/db/catalog/index_create.h b/src/mongo/db/catalog/multi_index_block.h
index 62d9d29eb13..d28c53ca87e 100644
--- a/src/mongo/db/catalog/index_create.h
+++ b/src/mongo/db/catalog/multi_index_block.h
@@ -34,10 +34,8 @@
#include <vector>
#include "mongo/base/disallow_copying.h"
-#include "mongo/base/shim.h"
#include "mongo/base/status.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_catalog_impl.h"
#include "mongo/db/index/index_access_method.h"
#include "mongo/db/record_id.h"
#include "mongo/stdx/functional.h"
@@ -61,73 +59,8 @@ class OperationContext;
*/
class MultiIndexBlock {
public:
- class Impl {
- public:
- virtual ~Impl() = 0;
-
- virtual void allowBackgroundBuilding() = 0;
-
- virtual void allowInterruption() = 0;
-
- virtual void ignoreUniqueConstraint() = 0;
-
- virtual void removeExistingIndexes(std::vector<BSONObj>* specs) const = 0;
-
- virtual StatusWith<std::vector<BSONObj>> init(const std::vector<BSONObj>& specs) = 0;
-
- virtual StatusWith<std::vector<BSONObj>> init(const BSONObj& spec) = 0;
-
- virtual Status insertAllDocumentsInCollection() = 0;
-
- virtual Status insert(const BSONObj& wholeDocument, const RecordId& loc) = 0;
-
- virtual Status doneInserting(std::set<RecordId>* dupsOut = NULL) = 0;
-
- virtual void commit(stdx::function<void(const BSONObj& spec)> onCreateFn) = 0;
-
- virtual void abortWithoutCleanup() = 0;
-
- virtual bool getBuildInBackground() const = 0;
- };
-
-private:
- std::unique_ptr<Impl> _pimpl;
-
- // This structure exists to give us a customization point to decide how to force users of this
- // class to depend upon the corresponding `index_create.cpp` Translation Unit (TU). All public
- // forwarding functions call `_impl(), and `_impl` creates an instance of this structure.
- struct TUHook {
- static void hook() noexcept;
-
- explicit inline TUHook() noexcept {
- if (kDebugBuild)
- this->hook();
- }
- };
-
- inline const Impl& _impl() const {
- TUHook{};
- return *this->_pimpl;
- }
-
- inline Impl& _impl() {
- TUHook{};
- return *this->_pimpl;
- }
-
-public:
- static MONGO_DECLARE_SHIM((OperationContext * opCtx,
- Collection* collection,
- PrivateTo<MultiIndexBlock>)
- ->std::unique_ptr<Impl>) makeImpl;
-
- inline ~MultiIndexBlock() = default;
-
- /**
- * Neither pointer is owned.
- */
- inline explicit MultiIndexBlock(OperationContext* const opCtx, Collection* const collection)
- : _pimpl(makeImpl(opCtx, collection, PrivateCall<MultiIndexBlock>{})) {}
+ MultiIndexBlock() = default;
+ virtual ~MultiIndexBlock() = default;
/**
* By default we ignore the 'background' flag in specs when building an index. If this is
@@ -137,17 +70,13 @@ public:
* indexes in the background, but there is a performance benefit to building all in the
* foreground.
*/
- inline void allowBackgroundBuilding() {
- return this->_impl().allowBackgroundBuilding();
- }
+ virtual void allowBackgroundBuilding() = 0;
/**
* Call this before init() to allow the index build to be interrupted.
* This only affects builds using the insertAllDocumentsInCollection helper.
*/
- inline void allowInterruption() {
- return this->_impl().allowInterruption();
- }
+ virtual void allowInterruption() = 0;
/**
* By default we enforce the 'unique' flag in specs when building an index by failing.
@@ -156,17 +85,13 @@ public:
*
* If this is called, any dupsOut sets passed in will never be filled.
*/
- inline void ignoreUniqueConstraint() {
- return this->_impl().ignoreUniqueConstraint();
- }
+ virtual void ignoreUniqueConstraint() = 0;
/**
* Removes pre-existing indexes from 'specs'. If this isn't done, init() may fail with
* IndexAlreadyExists.
*/
- inline void removeExistingIndexes(std::vector<BSONObj>* const specs) const {
- return this->_impl().removeExistingIndexes(specs);
- }
+ virtual void removeExistingIndexes(std::vector<BSONObj>* const specs) const = 0;
/**
* Prepares the index(es) for building and returns the canonicalized form of the requested index
@@ -176,13 +101,9 @@ public:
*
* Requires holding an exclusive database lock.
*/
- inline StatusWith<std::vector<BSONObj>> init(const std::vector<BSONObj>& specs) {
- return this->_impl().init(specs);
- }
+ virtual StatusWith<std::vector<BSONObj>> init(const std::vector<BSONObj>& specs) = 0;
- inline StatusWith<std::vector<BSONObj>> init(const BSONObj& spec) {
- return this->_impl().init(spec);
- }
+ virtual StatusWith<std::vector<BSONObj>> init(const BSONObj& spec) = 0;
/**
* Inserts all documents in the Collection into the indexes and logs with timing info.
@@ -196,9 +117,7 @@ public:
*
* Should not be called inside of a WriteUnitOfWork.
*/
- inline Status insertAllDocumentsInCollection() {
- return this->_impl().insertAllDocumentsInCollection();
- }
+ virtual Status insertAllDocumentsInCollection() = 0;
/**
* Call this after init() for each document in the collection.
@@ -207,9 +126,7 @@ public:
*
* Should be called inside of a WriteUnitOfWork.
*/
- inline Status insert(const BSONObj& wholeDocument, const RecordId& loc) {
- return this->_impl().insert(wholeDocument, loc);
- }
+ virtual Status insert(const BSONObj& wholeDocument, const RecordId& loc) = 0;
/**
* Call this after the last insert(). This gives the index builder a chance to do any
@@ -223,9 +140,7 @@ public:
*
* Should not be called inside of a WriteUnitOfWork.
*/
- inline Status doneInserting(std::set<RecordId>* const dupsOut = nullptr) {
- return this->_impl().doneInserting(dupsOut);
- }
+ virtual Status doneInserting(std::set<RecordId>* const dupsOut = nullptr) = 0;
/**
* Marks the index ready for use. Should only be called as the last method after
@@ -238,9 +153,7 @@ public:
*
* Requires holding an exclusive database lock.
*/
- inline void commit(stdx::function<void(const BSONObj& spec)> onCreateFn = nullptr) {
- return this->_impl().commit(onCreateFn);
- }
+ virtual void commit(stdx::function<void(const BSONObj& spec)> onCreateFn = nullptr) = 0;
/**
* May be called at any time after construction but before a successful commit(). Suppresses
@@ -256,12 +169,8 @@ public:
* Does not matter whether it is called inside of a WriteUnitOfWork. Will not be rolled
* back.
*/
- inline void abortWithoutCleanup() {
- return this->_impl().abortWithoutCleanup();
- }
+ virtual void abortWithoutCleanup() = 0;
- inline bool getBuildInBackground() const {
- return this->_impl().getBuildInBackground();
- }
+ virtual bool getBuildInBackground() const = 0;
};
} // namespace mongo
diff --git a/src/mongo/db/catalog/index_create_impl.cpp b/src/mongo/db/catalog/multi_index_block_impl.cpp
index 0b65af8ca81..b3eb293e9d9 100644
--- a/src/mongo/db/catalog/index_create_impl.cpp
+++ b/src/mongo/db/catalog/multi_index_block_impl.cpp
@@ -30,7 +30,7 @@
#include "mongo/platform/basic.h"
-#include "mongo/db/catalog/index_create_impl.h"
+#include "mongo/db/catalog/multi_index_block_impl.h"
#include "mongo/base/error_codes.h"
#include "mongo/base/init.h"
@@ -74,12 +74,6 @@ MONGO_FAIL_POINT_DEFINE(hangAfterIndexBuildOf);
AtomicInt32 maxIndexBuildMemoryUsageMegabytes(500);
-MONGO_REGISTER_SHIM(MultiIndexBlock::makeImpl)
-(OperationContext* const opCtx, Collection* const collection, PrivateTo<MultiIndexBlock>)
- ->std::unique_ptr<MultiIndexBlock::Impl> {
- return stdx::make_unique<MultiIndexBlockImpl>(opCtx, collection);
-}
-
class ExportedMaxIndexBuildMemoryUsageParameter
: public ExportedServerParameter<std::int32_t, ServerParameterType::kStartupAndRuntime> {
public:
diff --git a/src/mongo/db/catalog/index_create_impl.h b/src/mongo/db/catalog/multi_index_block_impl.h
index b0e33d485d6..d614d97929a 100644
--- a/src/mongo/db/catalog/index_create_impl.h
+++ b/src/mongo/db/catalog/multi_index_block_impl.h
@@ -28,7 +28,7 @@
#pragma once
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include <memory>
#include <set>
@@ -60,7 +60,7 @@ class OperationContext;
* destructed from inside of a WriteUnitOfWork as any cleanup needed should never be rolled back
* (as it is itself essentially a form of rollback, you don't want to "rollback the rollback").
*/
-class MultiIndexBlockImpl : public MultiIndexBlock::Impl {
+class MultiIndexBlockImpl : public MultiIndexBlock {
MONGO_DISALLOW_COPYING(MultiIndexBlockImpl);
public:
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index 45053d05d67..e810104a57d 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -38,7 +38,7 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/drop_collection.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -420,7 +420,8 @@ Status renameCollectionCommon(OperationContext* opCtx,
// Copy the index descriptions from the source collection, adjusting the ns field.
{
- MultiIndexBlock indexer(opCtx, tmpColl);
+ auto indexerPtr = tmpColl->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
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 35c28353486..65368e38199 100644
--- a/src/mongo/db/catalog/rename_collection_test.cpp
+++ b/src/mongo/db/catalog/rename_collection_test.cpp
@@ -34,7 +34,7 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/collection_options.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/catalog/rename_collection.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
@@ -404,7 +404,8 @@ void _createIndex(OperationContext* opCtx,
<< "ns"
<< nss.ns());
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
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 9345088843a..98b53546a62 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -42,7 +42,7 @@
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/list_collections_filter.h"
#include "mongo/db/commands/rename_collection.h"
@@ -390,7 +390,8 @@ 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.
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
indexer.allowInterruption();
indexer.removeExistingIndexes(&indexesToBuild);
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index a4edf0b000e..659863858d2 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -36,8 +36,8 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/command_generic_argument.h"
#include "mongo/db/commands.h"
@@ -351,7 +351,8 @@ public:
statsTracker.emplace(opCtx, ns, Top::LockType::WriteLocked, dbProfilingLevel);
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
indexer.allowBackgroundBuilding();
indexer.allowInterruption();
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 95452e0024c..2ad2e5b9074 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -41,8 +41,8 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -200,7 +200,7 @@ public:
WriteUnitOfWork wunit(opCtx);
collection->getIndexCatalog()->dropAllIndexes(opCtx, true);
- indexer = stdx::make_unique<MultiIndexBlock>(opCtx, collection);
+ indexer = collection->createMultiIndexBlock(opCtx);
swIndexesToRebuild = indexer->init(all);
uassertStatusOK(swIndexesToRebuild.getStatus());
diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp
index c286ef21e1d..a7ca95bd151 100644
--- a/src/mongo/db/commands/rename_collection_cmd.cpp
+++ b/src/mongo/db/commands/rename_collection_cmd.cpp
@@ -33,7 +33,7 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/catalog/rename_collection.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 2c29260a9e9..676d7c104de 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -35,7 +35,6 @@
#include <boost/filesystem/operations.hpp>
#include <fstream>
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/index/btree_access_method.h"
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index d4ef6171228..2fc9a134258 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -35,7 +35,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/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
@@ -195,7 +195,8 @@ Status IndexBuilder::_build(OperationContext* opCtx,
CurOp::get(opCtx)->setOpDescription_inlock(_index);
}
- MultiIndexBlock indexer(opCtx, coll);
+ auto indexerPtr = coll->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
indexer.allowInterruption();
if (allowBackgroundBuilding)
indexer.allowBackgroundBuilding();
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
index cec89996944..0363debbb70 100644
--- a/src/mongo/db/index_rebuilder.cpp
+++ b/src/mongo/db/index_rebuilder.cpp
@@ -40,7 +40,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/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/service_context.h"
@@ -80,7 +80,8 @@ void checkNS(OperationContext* opCtx, const std::list<std::string>& nsToCheck) {
}
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
{
WriteUnitOfWork wunit(opCtx);
diff --git a/src/mongo/db/repair_database.cpp b/src/mongo/db/repair_database.cpp
index 9b64c6eaf3b..15691a95d0b 100644
--- a/src/mongo/db/repair_database.cpp
+++ b/src/mongo/db/repair_database.cpp
@@ -45,8 +45,8 @@
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/catalog/namespace_uuid_cache.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -145,7 +145,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.reset(new MultiIndexBlock(opCtx, collection.get()));
+ indexer = collection->createMultiIndexBlock(opCtx);
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/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index 276aaba8c11..cf2f3cbf8f5 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -35,7 +35,7 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/catalog/collection.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -59,9 +59,8 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(ServiceContext::UniqueClient&
_opCtx{std::move(opCtx)},
_autoColl{std::move(autoColl)},
_nss{_autoColl->getCollection()->ns()},
- _idIndexBlock(stdx::make_unique<MultiIndexBlock>(_opCtx.get(), _autoColl->getCollection())),
- _secondaryIndexesBlock(
- stdx::make_unique<MultiIndexBlock>(_opCtx.get(), _autoColl->getCollection())),
+ _idIndexBlock(_autoColl->getCollection()->createMultiIndexBlock(_opCtx.get())),
+ _secondaryIndexesBlock(_autoColl->getCollection()->createMultiIndexBlock(_opCtx.get())),
_idIndexSpec(idIndexSpec.getOwned()) {
invariant(_opCtx);
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.h b/src/mongo/db/repl/collection_bulk_loader_impl.h
index 37eb5a9f6e4..871d6e041ac 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.h
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.h
@@ -33,7 +33,7 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/bson/bsonobj.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/collection_bulk_loader.h"
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index 11133a1bd6f..fe2ce26e1fc 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -37,7 +37,7 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
@@ -174,7 +174,8 @@ int createIndexForColl(OperationContext* opCtx,
NamespaceString nss,
BSONObj indexSpec) {
Lock::DBLock dbLock(opCtx, nss.db(), MODE_X);
- MultiIndexBlock indexer(opCtx, coll);
+ auto indexerPtr = coll->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
ASSERT_OK(indexer.init(indexSpec).getStatus());
WriteUnitOfWork wunit(opCtx);
indexer.commit();
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 65540f5ac78..ce7ef72d27c 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -49,7 +49,6 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h
index 48de98cf184..31802b9a387 100644
--- a/src/mongo/db/repl/storage_interface_impl.h
+++ b/src/mongo/db/repl/storage_interface_impl.h
@@ -35,7 +35,6 @@
#include "mongo/base/string_data.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/timestamp.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/storage_interface.h"
diff --git a/src/mongo/db/repl/storage_interface_impl_test.cpp b/src/mongo/db/repl/storage_interface_impl_test.cpp
index 66787596d28..6b417bdb19e 100644
--- a/src/mongo/db/repl/storage_interface_impl_test.cpp
+++ b/src/mongo/db/repl/storage_interface_impl_test.cpp
@@ -134,7 +134,8 @@ int createIndexForColl(OperationContext* opCtx, NamespaceString nss, BSONObj ind
AutoGetCollection autoColl(opCtx, nss, MODE_X);
auto coll = autoColl.getCollection();
- MultiIndexBlock indexer(opCtx, coll);
+ auto indexerPtr = coll->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
ASSERT_OK(indexer.init(indexSpec).getStatus());
WriteUnitOfWork wunit(opCtx);
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript
index 458e8bd7148..8583886b96d 100644
--- a/src/mongo/db/s/SConscript
+++ b/src/mongo/db/s/SConscript
@@ -66,7 +66,6 @@ env.Library(
'split_vector.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/catalog/index_create',
'$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 79ad4403bb2..ddfc578bdf7 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -38,7 +38,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/document_validation.h"
-#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/namespace_string.h"
@@ -633,7 +633,8 @@ void MigrationDestinationManager::cloneCollectionIndexesAndOptions(OperationCont
collection = db->getCollection(opCtx, nss);
}
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
indexer.removeExistingIndexes(&donorIndexSpecs);
if (!donorIndexSpecs.empty()) {
diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp
index c022879e8d0..67db3184574 100644
--- a/src/mongo/db/system_index.cpp
+++ b/src/mongo/db/system_index.cpp
@@ -38,8 +38,8 @@
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_catalog.h"
-#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/catalog/multi_index_block.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
@@ -122,7 +122,8 @@ void generateSystemIndexForExistingCollection(OperationContext* opCtx,
log() << "No authorization index detected on " << ns
<< " collection. Attempting to recover by creating an index with spec: " << indexSpec;
- MultiIndexBlock indexer(opCtx, collection);
+ auto indexerPtr = collection->createMultiIndexBlock(opCtx);
+ MultiIndexBlock& indexer(*indexerPtr);
writeConflictRetry(opCtx, "authorization index regeneration", ns.ns(), [&] {
fassert(40453, indexer.init(indexSpec));