diff options
author | Kevin Cherkauer <kevin.cherkauer@mongodb.com> | 2023-01-27 22:08:41 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-27 22:49:40 +0000 |
commit | d0c617dbf2dfbd15e30dc33102cdfde5113e44bb (patch) | |
tree | a369c547acc6d454b99ecf59a651b545bbfb91b2 | |
parent | 2c476fca4c0ee33312acd7591e8a0a2d7ac9020e (diff) | |
download | mongo-d0c617dbf2dfbd15e30dc33102cdfde5113e44bb.tar.gz |
SERVER-67446 Ensure consistent wildcardProjection specs in catalog
34 files changed, 212 insertions, 369 deletions
diff --git a/jstests/noPassthrough/sharded_index_projection_verbatim_persistence.js b/jstests/noPassthrough/sharded_index_projection_verbatim_persistence.js new file mode 100644 index 00000000000..54741a08f7d --- /dev/null +++ b/jstests/noPassthrough/sharded_index_projection_verbatim_persistence.js @@ -0,0 +1,52 @@ +/** + * Tests that index projections are persisted in the originally submitted form, as opposed to + * normalized form, in the catalog consistently across all shards. Exercises the fix for + * SERVER-67446. + * @tags: [ + * # Uses index building in background + * requires_background_index, + * requires_fcv_60, + * ] + + */ +(function() { +"use strict"; + +const st = new ShardingTest({shards: 3, rs: {nodes: 1}}); +const dbName = "test"; +const collName = "user"; +const ns = dbName + "." + collName; + +assert.commandWorked(st.s.adminCommand({enableSharding: dbName})); +st.ensurePrimaryShard(dbName, st.shard0.shardName); + +assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: "hashed"}})); + +const kProjectionDoc = { + "name": 0, + "type": 0, + "a.b": 0, + "_id": 1 +}; + +// Creates a wildcard index with a wildcardProjection that normalization would change and verifies +// the persisted projection doc on each shard matches the original, unnormalized version. +const kWildcardIndexName = "wc_index"; +st.s.getCollection(ns).createIndex({"$**": 1}, + {name: kWildcardIndexName, wildcardProjection: kProjectionDoc}); +let shardCatalogs = + st.s.getCollection(ns) + .aggregate([ + {$listCatalog: {}}, + {$unwind: "$md.indexes"}, + {$match: {"md.indexes.spec.name": kWildcardIndexName}}, + {$project: {shard: 1, wildcardProjection: "$md.indexes.spec.wildcardProjection"}} + ]) + .toArray(); +assert.eq(shardCatalogs.length, 3, shardCatalogs); +for (const catEntry of shardCatalogs) { + assert.eq(catEntry.wildcardProjection, kProjectionDoc, shardCatalogs); +} + +st.stop(); +})(); diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 727155fc87a..aeed37ed277 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -1046,7 +1046,7 @@ env.Library( LIBDEPS_PRIVATE=[ 'bson/dotted_path_support', 'catalog/collection_options', - 'index/index_descriptor', + 'index/index_access_method', 's/sharding_api_d', ], ) @@ -1555,7 +1555,6 @@ env.Library( LIBDEPS=[ '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/auth/auth_checks', - '$BUILD_DIR/mongo/db/index/index_access_methods', '$BUILD_DIR/mongo/scripting/scripting', '$BUILD_DIR/mongo/util/background_job', '$BUILD_DIR/mongo/util/elapsed_tracker', @@ -1580,8 +1579,7 @@ env.Library( 'exec/sort_executor', 'exec/working_set', 'fts/base_fts', - 'index/index_descriptor', - 'index/key_generator', + 'index/index_access_method', 'logical_session_cache', 'matcher/expressions_mongod_only', 'ops/parsed_update', @@ -2177,8 +2175,7 @@ env.Library( LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/catalog/catalog_impl', '$BUILD_DIR/mongo/db/commands/mongod', - '$BUILD_DIR/mongo/db/index/index_access_method_factory', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/s/sharding_runtime_d', '$BUILD_DIR/mongo/db/storage/devnull/storage_devnull', '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/storage_ephemeral_for_test', @@ -2418,8 +2415,6 @@ env.Library( 'ftdc/ftdc_mongod', 'fts/ftsmongod', 'index/index_access_method', - 'index/index_access_methods', - 'index/index_descriptor', 'index_builds_coordinator_mongod', 'initialize_snmp', 'introspect', @@ -2528,8 +2523,7 @@ env.Library( 'fle_crud_mongod', 'free_mon/free_mon_mongod', 'ftdc/ftdc_mongod', - 'index/index_access_method_factory', - 'index/index_access_methods', + 'index/index_access_method', 'index_builds_coordinator_mongod', 'initialize_snmp', 'keys_collection_client_direct', @@ -2636,8 +2630,7 @@ env.Library( '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/db/catalog/catalog_impl', '$BUILD_DIR/mongo/db/catalog/database_holder', - '$BUILD_DIR/mongo/db/index/index_access_method_factory', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/repl/replmocks', '$BUILD_DIR/mongo/db/s/sharding_api_d', '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/storage_ephemeral_for_test', diff --git a/src/mongo/db/auth/SConscript b/src/mongo/db/auth/SConscript index 57af14b709d..459415e171f 100644 --- a/src/mongo/db/auth/SConscript +++ b/src/mongo/db/auth/SConscript @@ -82,7 +82,7 @@ env.Library( '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/audit', '$BUILD_DIR/mongo/db/catalog/collection_options', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/op_observer', '$BUILD_DIR/mongo/db/op_observer_util', '$BUILD_DIR/mongo/db/repl/oplog_entry', diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript index 34ce8806607..0a22459bc19 100644 --- a/src/mongo/db/catalog/SConscript +++ b/src/mongo/db/catalog/SConscript @@ -169,8 +169,7 @@ env.Library( LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/common', - '$BUILD_DIR/mongo/db/index/index_descriptor', - '$BUILD_DIR/mongo/db/index/key_generator', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/index_names', '$BUILD_DIR/mongo/db/matcher/expressions', '$BUILD_DIR/mongo/db/query/collation/collator_factory_interface', @@ -210,7 +209,6 @@ env.Library( '$BUILD_DIR/mongo/db/collection_index_usage_tracker', '$BUILD_DIR/mongo/db/common', '$BUILD_DIR/mongo/db/index/index_access_method', - '$BUILD_DIR/mongo/db/index/index_descriptor', '$BUILD_DIR/mongo/db/index_names', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/ttl_collection_cache', @@ -364,8 +362,6 @@ env.Library( '$BUILD_DIR/mongo/db/curop', '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/index/index_access_method', - '$BUILD_DIR/mongo/db/index/index_access_method_factory', - '$BUILD_DIR/mongo/db/index/index_access_methods', '$BUILD_DIR/mongo/db/multitenancy', '$BUILD_DIR/mongo/db/op_observer', '$BUILD_DIR/mongo/db/record_id_helpers', diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 03fc879ba9f..abb9b0675c6 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -555,7 +555,7 @@ IndexCatalogEntry* IndexCatalogImpl::createIndexEntry(OperationContext* opCtx, opCtx, collection->ns(), collOptions, ident, desc); std::unique_ptr<IndexAccessMethod> accessMethod = - IndexAccessMethodFactory::get(opCtx)->make(entry.get(), std::move(sdi)); + IndexAccessMethod::make(entry.get(), std::move(sdi)); entry->init(std::move(accessMethod)); diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript index 848d0726e79..87a188294aa 100644 --- a/src/mongo/db/commands/SConscript +++ b/src/mongo/db/commands/SConscript @@ -738,7 +738,7 @@ env.Library( LIBDEPS=[ '$BUILD_DIR/mongo/db/commands/servers', '$BUILD_DIR/mongo/db/db_raii', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/pipeline/process_interface/mongo_process_interface', '$BUILD_DIR/mongo/db/pipeline/process_interface/mongod_process_interface_factory', '$BUILD_DIR/mongo/db/query/map_reduce_output_format', diff --git a/src/mongo/db/cst/SConscript b/src/mongo/db/cst/SConscript index 16f5a25932f..917ae792c2a 100644 --- a/src/mongo/db/cst/SConscript +++ b/src/mongo/db/cst/SConscript @@ -39,7 +39,7 @@ env.CppUnitTest( ], LIBDEPS=[ # $text depends on FTSAccessMethod. - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/matcher/expressions_mongod_only', '$BUILD_DIR/mongo/db/query/query_test_service_context', 'cst', diff --git a/src/mongo/db/exec/SConscript b/src/mongo/db/exec/SConscript index e8d1cb729a7..eac1c6a3105 100644 --- a/src/mongo/db/exec/SConscript +++ b/src/mongo/db/exec/SConscript @@ -109,7 +109,7 @@ env.Library( 'stagedebug_cmd.cpp' ], LIBDEPS=[ - "$BUILD_DIR/mongo/db/index/index_access_methods", + "$BUILD_DIR/mongo/db/index/index_access_method", "$BUILD_DIR/mongo/db/query_exec", ], LIBDEPS_PRIVATE=[ diff --git a/src/mongo/db/exec/sbe/SConscript b/src/mongo/db/exec/sbe/SConscript index 023787748a0..f8246baf556 100644 --- a/src/mongo/db/exec/sbe/SConscript +++ b/src/mongo/db/exec/sbe/SConscript @@ -23,7 +23,7 @@ env.Library( '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/exec/js_function', '$BUILD_DIR/mongo/db/fts/base_fts', - '$BUILD_DIR/mongo/db/index/key_generator', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/query/collation/collator_interface', '$BUILD_DIR/mongo/db/query/datetime/date_time_support', '$BUILD_DIR/mongo/db/query/query_index_bounds', diff --git a/src/mongo/db/index/SConscript b/src/mongo/db/index/SConscript index cb3dc9de03e..1e970fb264f 100644 --- a/src/mongo/db/index/SConscript +++ b/src/mongo/db/index/SConscript @@ -4,57 +4,12 @@ Import("env") env = env.Clone() -env.Library( - target='index_descriptor', - source=[ - 'index_descriptor.cpp', - ], - LIBDEPS_PRIVATE=[ - '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/catalog/index_catalog', - '$BUILD_DIR/mongo/db/index_names', - '$BUILD_DIR/mongo/db/matcher/expressions', - '$BUILD_DIR/mongo/db/namespace_string', - '$BUILD_DIR/mongo/db/query/collation/collator_factory_interface', - ], -) - -env.Library( - target='key_generator', - source=[ - 'btree_key_generator.cpp', - 'column_key_generator.cpp', - 'expression_keys_private.cpp', - 'sort_key_generator.cpp', - 'wildcard_key_generator.cpp', - ], - LIBDEPS_PRIVATE=[ - '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/bson/dotted_path_support', - '$BUILD_DIR/mongo/db/exec/projection_executor', - '$BUILD_DIR/mongo/db/exec/working_set', - '$BUILD_DIR/mongo/db/fts/base_fts', - '$BUILD_DIR/mongo/db/geo/geoparser', - '$BUILD_DIR/mongo/db/index_names', - '$BUILD_DIR/mongo/db/mongohasher', - '$BUILD_DIR/mongo/db/pipeline/document_path_support', - '$BUILD_DIR/mongo/db/query/collation/collator_interface', - '$BUILD_DIR/mongo/db/query/projection_ast', - '$BUILD_DIR/mongo/db/query/sort_pattern', - '$BUILD_DIR/mongo/db/record_id_helpers', - '$BUILD_DIR/mongo/db/timeseries/timeseries_conversion_util', - '$BUILD_DIR/third_party/s2/s2', - 'expression_params', - 'index_descriptor', - ], -) - env.Benchmark( target='key_gen_bm', source='key_gen_bm.cpp', LIBDEPS=[ '$BUILD_DIR/mongo/base', - 'key_generator', + 'index_access_method', ], ) @@ -76,34 +31,50 @@ env.Library( ] ) -env.Library( - target='index_access_method_factory', - source=[ - 'index_access_method_factory.cpp', - ], - LIBDEPS_PRIVATE=[ - '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/index_names', - ], -) - serveronlyEnv = env.Clone() serveronlyEnv.InjectThirdParty(libraries=['snappy']) serveronlyEnv.Library( target="index_access_method", source=[ + '2d_access_method.cpp', + 'btree_access_method.cpp', + 'btree_key_generator.cpp', + 'column_key_generator.cpp', 'duplicate_key_tracker.cpp', + 'expression_keys_private.cpp', + 'fts_access_method.cpp', + 'hash_access_method.cpp', 'index_access_method.cpp', 'index_build_interceptor.cpp', 'index_build_interceptor.idl', + 'index_descriptor.cpp', + 's2_access_method.cpp', + 's2_bucket_access_method.cpp', 'skipped_record_tracker.cpp', + 'sort_key_generator.cpp', + 'wildcard_access_method.cpp', + 'wildcard_key_generator.cpp', ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/base', + '$BUILD_DIR/mongo/db/bson/dotted_path_support', + '$BUILD_DIR/mongo/db/catalog/collection', + '$BUILD_DIR/mongo/db/catalog/index_catalog', '$BUILD_DIR/mongo/db/catalog/index_catalog_entry', '$BUILD_DIR/mongo/db/concurrency/exception_util', '$BUILD_DIR/mongo/db/curop', + '$BUILD_DIR/mongo/db/exec/projection_executor', + '$BUILD_DIR/mongo/db/exec/working_set', + '$BUILD_DIR/mongo/db/fts/base_fts', + '$BUILD_DIR/mongo/db/geo/geoparser', + '$BUILD_DIR/mongo/db/mongohasher', '$BUILD_DIR/mongo/db/multi_key_path_tracker', + '$BUILD_DIR/mongo/db/pipeline/document_path_support', + '$BUILD_DIR/mongo/db/query/collation/collator_factory_interface', + '$BUILD_DIR/mongo/db/query/collation/collator_interface', + '$BUILD_DIR/mongo/db/query/projection_ast', + '$BUILD_DIR/mongo/db/query/sort_pattern', + '$BUILD_DIR/mongo/db/record_id_helpers', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/resumable_index_builds_idl', '$BUILD_DIR/mongo/db/service_context', @@ -115,36 +86,14 @@ serveronlyEnv.Library( '$BUILD_DIR/mongo/db/storage/key_string', '$BUILD_DIR/mongo/db/storage/record_store_base', '$BUILD_DIR/mongo/db/storage/storage_options', + '$BUILD_DIR/mongo/db/timeseries/timeseries_conversion_util', '$BUILD_DIR/mongo/db/vector_clock', '$BUILD_DIR/mongo/idl/server_parameter', '$BUILD_DIR/mongo/util/progress_meter', + '$BUILD_DIR/third_party/s2/s2', '$BUILD_DIR/third_party/shim_snappy', - 'index_descriptor', - ], -) - -env.Library( - target="index_access_methods", - source=[ - "2d_access_method.cpp", - "btree_access_method.cpp", - "fts_access_method.cpp", - "hash_access_method.cpp", - "index_access_method_factory_impl.cpp", - "s2_access_method.cpp", - "s2_bucket_access_method.cpp", - "wildcard_access_method.cpp", - ], - LIBDEPS=[ - 'index_access_method', - ], - LIBDEPS_PRIVATE=[ - '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/fts/base_fts', - '$BUILD_DIR/mongo/db/index_names', 'expression_params', - 'key_generator', - ] + ], ) env.CppUnitTest( @@ -170,6 +119,6 @@ env.CppUnitTest( '$BUILD_DIR/mongo/db/record_id_helpers', '$BUILD_DIR/mongo/db/sorter/sorter_stats', 'expression_params', - 'key_generator', + 'index_access_method', ], ) diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 8e4bc4e4ead..72cd88337c6 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -31,7 +31,7 @@ #include "mongo/platform/basic.h" -#include "mongo/db/index/btree_access_method.h" +#include "mongo/db/index/index_access_method.h" #include <utility> #include <vector> @@ -44,8 +44,15 @@ #include "mongo/db/commands/server_status.h" #include "mongo/db/concurrency/exception_util.h" #include "mongo/db/curop.h" +#include "mongo/db/index/2d_access_method.h" +#include "mongo/db/index/btree_access_method.h" +#include "mongo/db/index/fts_access_method.h" +#include "mongo/db/index/hash_access_method.h" #include "mongo/db/index/index_build_interceptor.h" #include "mongo/db/index/index_descriptor.h" +#include "mongo/db/index/s2_access_method.h" +#include "mongo/db/index/s2_bucket_access_method.h" +#include "mongo/db/index/wildcard_access_method.h" #include "mongo/db/jsobj.h" #include "mongo/db/keypattern.h" #include "mongo/db/operation_context.h" @@ -53,6 +60,7 @@ #include "mongo/db/repl/timestamp_block.h" #include "mongo/db/sorter/sorter.h" #include "mongo/db/storage/execution_context.h" +#include "mongo/db/storage/kv/kv_engine.h" #include "mongo/db/storage/storage_options.h" #include "mongo/logv2/log.h" #include "mongo/platform/atomic_word.h" @@ -71,6 +79,35 @@ MONGO_FAIL_POINT_DEFINE(hangIndexBuildDuringBulkLoadPhaseSecond); MONGO_FAIL_POINT_DEFINE(hangDuringIndexBuildBulkLoadYield); MONGO_FAIL_POINT_DEFINE(hangDuringIndexBuildBulkLoadYieldSecond); +/** + * Static factory method that constructs and returns an appropriate IndexAccessMethod depending on + * the type of the index. + */ +std::unique_ptr<IndexAccessMethod> IndexAccessMethod::make( + IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> sortedDataInterface) { + auto desc = entry->descriptor(); + const std::string& type = desc->getAccessMethodName(); + if ("" == type) + return std::make_unique<BtreeAccessMethod>(entry, std::move(sortedDataInterface)); + else if (IndexNames::HASHED == type) + return std::make_unique<HashAccessMethod>(entry, std::move(sortedDataInterface)); + else if (IndexNames::GEO_2DSPHERE == type) + return std::make_unique<S2AccessMethod>(entry, std::move(sortedDataInterface)); + else if (IndexNames::GEO_2DSPHERE_BUCKET == type) + return std::make_unique<S2BucketAccessMethod>(entry, std::move(sortedDataInterface)); + else if (IndexNames::TEXT == type) + return std::make_unique<FTSAccessMethod>(entry, std::move(sortedDataInterface)); + else if (IndexNames::GEO_2D == type) + return std::make_unique<TwoDAccessMethod>(entry, std::move(sortedDataInterface)); + else if (IndexNames::WILDCARD == type) + return std::make_unique<WildcardAccessMethod>(entry, std::move(sortedDataInterface)); + LOGV2(20688, + "Can't find index for keyPattern {keyPattern}", + "Can't find index for keyPattern", + "keyPattern"_attr = desc->keyPattern()); + fassertFailed(31021); +} + namespace { /** diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 6b0404512c5..18d96a2218d 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -73,6 +73,9 @@ public: IndexAccessMethod() = default; virtual ~IndexAccessMethod() = default; + static std::unique_ptr<IndexAccessMethod> make( + IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> sortedDataInterface); + /** * Equivalent to (but shorter and faster than): dynamic_cast<SortedDataIndexAccessMethod*>(this) */ @@ -246,23 +249,6 @@ public: }; /** - * Factory class that constructs an IndexAccessMethod depending on the type of index. - */ -class IndexAccessMethodFactory { -public: - IndexAccessMethodFactory() = default; - virtual ~IndexAccessMethodFactory() = default; - - static IndexAccessMethodFactory* get(ServiceContext* service); - static IndexAccessMethodFactory* get(OperationContext* opCtx); - static void set(ServiceContext* service, - std::unique_ptr<IndexAccessMethodFactory> collectionFactory); - - virtual std::unique_ptr<IndexAccessMethod> make( - IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> sortedDataInterface) = 0; -}; - -/** * Updates are two steps: verify that it's a valid update, and perform it. * prepareUpdate fills out the UpdateStatus and update actually applies it. */ diff --git a/src/mongo/db/index/index_access_method_factory.cpp b/src/mongo/db/index/index_access_method_factory.cpp deleted file mode 100644 index 986ed2d8967..00000000000 --- a/src/mongo/db/index/index_access_method_factory.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (C) 2019-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/platform/basic.h" - -#include "mongo/db/index/index_access_method.h" - -namespace mongo { -namespace { -const auto getFactory = - ServiceContext::declareDecoration<std::unique_ptr<IndexAccessMethodFactory>>(); -} // namespace - -IndexAccessMethodFactory* IndexAccessMethodFactory::get(ServiceContext* service) { - return getFactory(service).get(); -} - -IndexAccessMethodFactory* IndexAccessMethodFactory::get(OperationContext* opCtx) { - return getFactory(opCtx->getServiceContext()).get(); -} - -void IndexAccessMethodFactory::set(ServiceContext* service, - std::unique_ptr<IndexAccessMethodFactory> newFactory) { - auto& factory = getFactory(service); - factory = std::move(newFactory); -} -} // namespace mongo diff --git a/src/mongo/db/index/index_access_method_factory_impl.cpp b/src/mongo/db/index/index_access_method_factory_impl.cpp deleted file mode 100644 index 2f1610deee6..00000000000 --- a/src/mongo/db/index/index_access_method_factory_impl.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (C) 2019-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. - */ - -#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kIndex - -#include "mongo/platform/basic.h" - -#include "mongo/db/index/index_access_method_factory_impl.h" - -#include "mongo/db/index/2d_access_method.h" -#include "mongo/db/index/btree_access_method.h" -#include "mongo/db/index/fts_access_method.h" -#include "mongo/db/index/hash_access_method.h" -#include "mongo/db/index/s2_access_method.h" -#include "mongo/db/index/s2_bucket_access_method.h" -#include "mongo/db/index/wildcard_access_method.h" -#include "mongo/logv2/log.h" - -namespace mongo { - -std::unique_ptr<IndexAccessMethod> IndexAccessMethodFactoryImpl::make( - IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> sortedDataInterface) { - auto desc = entry->descriptor(); - const std::string& type = desc->getAccessMethodName(); - if ("" == type) - return std::make_unique<BtreeAccessMethod>(entry, std::move(sortedDataInterface)); - else if (IndexNames::HASHED == type) - return std::make_unique<HashAccessMethod>(entry, std::move(sortedDataInterface)); - else if (IndexNames::GEO_2DSPHERE == type) - return std::make_unique<S2AccessMethod>(entry, std::move(sortedDataInterface)); - else if (IndexNames::GEO_2DSPHERE_BUCKET == type) - return std::make_unique<S2BucketAccessMethod>(entry, std::move(sortedDataInterface)); - else if (IndexNames::TEXT == type) - return std::make_unique<FTSAccessMethod>(entry, std::move(sortedDataInterface)); - else if (IndexNames::GEO_2D == type) - return std::make_unique<TwoDAccessMethod>(entry, std::move(sortedDataInterface)); - else if (IndexNames::WILDCARD == type) - return std::make_unique<WildcardAccessMethod>(entry, std::move(sortedDataInterface)); - LOGV2(20688, - "Can't find index for keyPattern {keyPattern}", - "Can't find index for keyPattern", - "keyPattern"_attr = desc->keyPattern()); - fassertFailed(31021); -} - -} // namespace mongo diff --git a/src/mongo/db/index/index_access_method_factory_impl.h b/src/mongo/db/index/index_access_method_factory_impl.h deleted file mode 100644 index dae1a2204ac..00000000000 --- a/src/mongo/db/index/index_access_method_factory_impl.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (C) 2019-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. - */ - -#pragma once - -#include "mongo/db/index/index_access_method.h" - -namespace mongo { - -class IndexAccessMethodFactoryImpl : public IndexAccessMethodFactory { -public: - IndexAccessMethodFactoryImpl() = default; - ~IndexAccessMethodFactoryImpl() = default; - - std::unique_ptr<IndexAccessMethod> make( - IndexCatalogEntry* entry, std::unique_ptr<SortedDataInterface> SortedDataInterface) final; -}; - -} // namespace mongo diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index 3f4dbd088ed..0fd676a8353 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -38,6 +38,8 @@ #include "mongo/bson/simple_bsonelement_comparator.h" #include "mongo/bson/unordered_fields_bsonobj_comparator.h" #include "mongo/db/catalog/index_catalog_entry.h" +#include "mongo/db/index/column_key_generator.h" +#include "mongo/db/index/wildcard_key_generator.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/server_options.h" @@ -109,6 +111,11 @@ constexpr StringData IndexDescriptor::kHiddenFieldName; constexpr StringData IndexDescriptor::kWeightsFieldName; constexpr StringData IndexDescriptor::kPrepareUniqueFieldName; +/** + * Constructs an IndexDescriptor object. Arguments: + * accessMethodName - one of the 'IndexNames::XXX' constants from index_names.cpp + * infoObj - options information + */ IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj infoObj) : _accessMethodName(accessMethodName), _indexType(IndexNames::nameToType(accessMethodName)), @@ -143,6 +150,16 @@ IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj in feature_flags::gCollModIndexUnique.isEnabled(serverGlobalParams.featureCompatibility)); _prepareUnique = prepareUniqueElement.trueValue(); } + + // If there is a wildcardProjection, compute and store the normalized version in + // '_normalizedProjection'. + BSONElement wildcardProjection = infoObj[IndexDescriptor::kPathProjectionFieldName]; + if (wildcardProjection) { + WildcardProjection indexPathProjection = WildcardKeyGenerator::createProjectionExecutor( + BSON("$**" << 1), wildcardProjection.Obj()); + _normalizedProjection = + indexPathProjection.exec()->serializeTransformation(boost::none).toBson(); + } } bool IndexDescriptor::isIndexVersionSupported(IndexVersion indexVersion) { @@ -162,10 +179,6 @@ IndexDescriptor::Comparison IndexDescriptor::compareIndexOptions( OperationContext* opCtx, const NamespaceString& ns, const IndexCatalogEntry* existingIndex) const { - // The compareIndexOptions method can only be reliably called on a candidate index which is - // being compared against an index that already exists in the catalog. - tassert(4765900, "This object must be a candidate index", !getEntry()); - auto existingIndexDesc = existingIndex->descriptor(); // We first check whether the key pattern is identical for both indexes. @@ -174,8 +187,15 @@ IndexDescriptor::Comparison IndexDescriptor::compareIndexOptions( return Comparison::kDifferent; } + // If the candidate has a wildcardProjection, we must compare the normalized versions, not the + // versions from the catalog which are kept as the user gave them and thus may be semantically + // identical to but syntactically different from the normalized form. There are no other types + // of index projections. Thus, if there is no projection, both the original and normalized + // projections will be empty BSON objects, so we can still do the comparison based on the + // normalized projection. static const UnorderedFieldsBSONObjComparator kUnorderedBSONCmp; - if (kUnorderedBSONCmp.evaluate(_projection != existingIndexDesc->_normalizedProjection)) { + if (kUnorderedBSONCmp.evaluate(_normalizedProjection != + existingIndexDesc->_normalizedProjection)) { return Comparison::kDifferent; } diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index f4f48cb35b9..5dd11a1c6a7 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -119,15 +119,36 @@ public: } /** - * Return the path projection spec, if one exists. This is only applicable for '$**' indexes. + * Return the path projection spec, if one exists. This is only applicable for wildcard ('$**') + * indexes. It is kept as originally specified by the createIndex() call, not normalized. + * + * It contains only the projection object that was contained in the field listed below from the + * original createIndex() parameters object, but it does NOT preserve the field name: + * - "wildcardProjection" (IndexDescriptor::kPathProjectionFieldName) + * + * This is set by the IndexDescriptor constructor and never changes after that. + * + * Example: db.a.createIndex({"$**":1}, {"name": "i1", "wildcardProjection": {"a.b": 1}}) + * return (unnormalized) object: {"a.b":{"$numberDouble":"1"}} */ const BSONObj& pathProjection() const { return _projection; } /** - * Returns the normalized path projection spec, if one exists. This is only applicable for '$**' - * indexes. + * Returns the normalized path projection spec, if one exists. This is only applicable for + * wildcard ('$**') indexes. It is the normalized version of the path projection and is used to + * determine whether a new index candidate from createIndex() duplicates an existing index. + * + * It contains the normalized projection object based on the original object that was contained + * in the field listed below from the original createIndex() parameters object, but it does NOT + * preserve the field name: + * - "wildcardProjection" (IndexDescriptor::kPathProjectionFieldName) + * + * This is set by the IndexDescriptor constructor and never changes after that. + * + * Example: db.a.createIndex({"$**":1}, {"name": "i1", "wildcardProjection": {"a.b": 1}}) + * return (normalized) object: {"a":{"b":true},"_id":false} */ const BSONObj& normalizedPathProjection() const { return _normalizedProjection; @@ -251,12 +272,6 @@ public: } private: - // This method should only ever be called by WildcardAccessMethod, to set the - // '_normalizedProjection' for descriptors associated with an existing IndexCatalogEntry. - void _setNormalizedPathProjection(BSONObj&& proj) { - _normalizedProjection = std::move(proj); - } - // What access method should we use for this index? std::string _accessMethodName; @@ -269,8 +284,8 @@ private: int64_t _numFields; // How many fields are indexed? BSONObj _keyPattern; - BSONObj _projection; - BSONObj _normalizedProjection; + BSONObj _projection; // for wildcardProjection / columnstoreProjection; never changes + BSONObj _normalizedProjection; // for wildcardProjection / columnstoreProjection; never changes std::string _indexName; bool _isIdIndex; bool _sparse; @@ -289,7 +304,6 @@ private: friend class IndexCatalog; friend class IndexCatalogEntryImpl; friend class IndexCatalogEntryContainer; - friend class WildcardAccessMethod; }; } // namespace mongo diff --git a/src/mongo/db/index/wildcard_access_method.cpp b/src/mongo/db/index/wildcard_access_method.cpp index 4ea3cfc261c..cdab87cbb04 100644 --- a/src/mongo/db/index/wildcard_access_method.cpp +++ b/src/mongo/db/index/wildcard_access_method.cpp @@ -45,15 +45,7 @@ WildcardAccessMethod::WildcardAccessMethod(IndexCatalogEntry* wildcardState, _indexCatalogEntry->getCollator(), getSortedDataInterface()->getKeyStringVersion(), getSortedDataInterface()->getOrdering(), - getSortedDataInterface()->rsKeyFormat()) { - // Normalize the 'wildcardProjection' index option to facilitate its comparison as part of - // index signature. - if (!_descriptor->pathProjection().isEmpty()) { - auto* projExec = getWildcardProjection()->exec(); - wildcardState->descriptor()->_setNormalizedPathProjection( - projExec->serializeTransformation(boost::none).toBson()); - } -} + getSortedDataInterface()->rsKeyFormat()) {} bool WildcardAccessMethod::shouldMarkIndexAsMultikey(size_t numberOfKeys, const KeyStringSet& multikeyMetadataKeys, diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index f16e991ffcd..b4fd8d4c5a4 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -3018,6 +3018,7 @@ std::vector<BSONObj> IndexBuildsCoordinator::prepareSpecListForCreate( return resultSpecs; } +// Returns normalized versions of 'indexSpecs' for the catalog. std::vector<BSONObj> IndexBuildsCoordinator::normalizeIndexSpecs( OperationContext* opCtx, const CollectionPtr& collection, @@ -3039,26 +3040,13 @@ std::vector<BSONObj> IndexBuildsCoordinator::normalizeIndexSpecs( // for clients to validate (via the listIndexes output) whether a given partialFilterExpression // is equivalent to the filter that they originally submitted. Omitting this normalization does // not impact our internal index comparison semantics, since we compare based on the parsed - // MatchExpression trees rather than the serialized BSON specs. See SERVER-54357. - - // If any of the specs describe wildcard indexes, normalize the wildcard projections if present. - // This will change all specs of the form {"a.b.c": 1} to normalized form {a: {b: {c : 1}}}. - std::transform(normalSpecs.begin(), normalSpecs.end(), normalSpecs.begin(), [](auto& spec) { - const auto kProjectionName = IndexDescriptor::kPathProjectionFieldName; - const auto pathProjectionSpec = spec.getObjectField(kProjectionName); - static const auto kWildcardKeyPattern = BSON("$**" << 1); - // It's illegal for the user to explicitly specify an empty wildcardProjection for creating - // a {"$**":1} index, and specify any wildcardProjection for a {"field.$**": 1} index. If - // the projection is empty, then it means that there is no projection to normalize. - if (pathProjectionSpec.isEmpty()) { - return spec; - } - auto wildcardProjection = - WildcardKeyGenerator::createProjectionExecutor(kWildcardKeyPattern, pathProjectionSpec); - auto normalizedProjection = - wildcardProjection.exec()->serializeTransformation(boost::none).toBson(); - return spec.addField(BSON(kProjectionName << normalizedProjection).firstElement()); - }); + // MatchExpression trees rather than the serialized BSON specs. + // + // For similar reasons we do not normalize index projection objects here, if any, so their + // original forms get persisted in the catalog. Projection normalization to detect whether a + // candidate new index would duplicate an existing index is done only in the memory-only + // 'IndexDescriptor._normalizedProjection' field. + return normalSpecs; } diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp index 73a05c69c42..93048fd4f53 100644 --- a/src/mongo/db/mongod_main.cpp +++ b/src/mongo/db/mongod_main.cpp @@ -85,7 +85,6 @@ #include "mongo/db/ftdc/ftdc_mongod.h" #include "mongo/db/ftdc/util.h" #include "mongo/db/global_settings.h" -#include "mongo/db/index/index_access_method_factory_impl.h" #include "mongo/db/index_builds_coordinator_mongod.h" #include "mongo/db/index_names.h" #include "mongo/db/initialize_server_global_state.h" @@ -1019,7 +1018,6 @@ void setUpCollectionShardingState(ServiceContext* serviceContext) { void setUpCatalog(ServiceContext* serviceContext) { DatabaseHolder::set(serviceContext, std::make_unique<DatabaseHolderImpl>()); - IndexAccessMethodFactory::set(serviceContext, std::make_unique<IndexAccessMethodFactoryImpl>()); Collection::Factory::set(serviceContext, std::make_unique<CollectionImpl::FactoryImpl>()); } diff --git a/src/mongo/db/op_msg_fuzzer_fixture.cpp b/src/mongo/db/op_msg_fuzzer_fixture.cpp index 89c81979a49..040f12ee32e 100644 --- a/src/mongo/db/op_msg_fuzzer_fixture.cpp +++ b/src/mongo/db/op_msg_fuzzer_fixture.cpp @@ -39,7 +39,6 @@ #include "mongo/db/catalog/database_holder_impl.h" #include "mongo/db/client.h" #include "mongo/db/index/index_access_method.h" -#include "mongo/db/index/index_access_method_factory_impl.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/repl_client_info.h" @@ -113,8 +112,6 @@ OpMsgFuzzerFixture::OpMsgFuzzerFixture(bool skipGlobalInitializers) _serviceContext, std::make_unique<CollectionShardingStateFactoryStandalone>(_serviceContext)); DatabaseHolder::set(_serviceContext, std::make_unique<DatabaseHolderImpl>()); - IndexAccessMethodFactory::set(_serviceContext, - std::make_unique<IndexAccessMethodFactoryImpl>()); Collection::Factory::set(_serviceContext, std::make_unique<CollectionImpl::FactoryImpl>()); // Setup the repl coordinator in standalone mode so we don't need an oplog etc. diff --git a/src/mongo/db/op_observer/SConscript b/src/mongo/db/op_observer/SConscript index 36cb605336f..21f062d96a3 100644 --- a/src/mongo/db/op_observer/SConscript +++ b/src/mongo/db/op_observer/SConscript @@ -25,7 +25,7 @@ env.Library( LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/bson/dotted_path_support', '$BUILD_DIR/mongo/db/catalog/collection_options', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/s/sharding_api_d', ], ) diff --git a/src/mongo/db/pipeline/SConscript b/src/mongo/db/pipeline/SConscript index acc4afe2069..b20f0074625 100644 --- a/src/mongo/db/pipeline/SConscript +++ b/src/mongo/db/pipeline/SConscript @@ -184,7 +184,7 @@ env.Library( ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/exec/sort_executor', - '$BUILD_DIR/mongo/db/index/key_generator', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/idl/idl_parser', ], ) @@ -353,7 +353,7 @@ pipelineEnv.Library( '$BUILD_DIR/mongo/db/exec/scoped_timer', '$BUILD_DIR/mongo/db/exec/sort_executor', '$BUILD_DIR/mongo/db/generic_cursor', - '$BUILD_DIR/mongo/db/index/key_generator', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/logical_session_cache', '$BUILD_DIR/mongo/db/logical_session_id_helpers', '$BUILD_DIR/mongo/db/matcher/expressions', diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript index 1f42baff54c..941e85c4b2c 100644 --- a/src/mongo/db/query/SConscript +++ b/src/mongo/db/query/SConscript @@ -61,7 +61,6 @@ env.Library( "$BUILD_DIR/mongo/db/commands/server_status_core", "$BUILD_DIR/mongo/db/exec/sbe/query_sbe_plan_stats", "$BUILD_DIR/mongo/db/index/expression_params", - "$BUILD_DIR/mongo/db/index/key_generator", "$BUILD_DIR/mongo/db/index_names", "canonical_query", "query_index_bounds", @@ -70,6 +69,7 @@ env.Library( ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/fts/base_fts', + '$BUILD_DIR/mongo/db/index/index_access_method', "$BUILD_DIR/mongo/db/record_id_helpers", "$BUILD_DIR/mongo/idl/server_parameter", ], diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index 812797ee6bc..52639388e26 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -118,7 +118,7 @@ env.Library( '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/db_raii', '$BUILD_DIR/mongo/db/dbhelpers', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/query_exec', '$BUILD_DIR/mongo/util/fail_point', 'oplog', @@ -703,7 +703,7 @@ env.Library( '$BUILD_DIR/mongo/db/commands/mongod_fcv', '$BUILD_DIR/mongo/db/common', '$BUILD_DIR/mongo/db/concurrency/lock_manager', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/kill_sessions_local', '$BUILD_DIR/mongo/db/mongod_options', '$BUILD_DIR/mongo/db/prepare_conflict_tracker', @@ -1680,7 +1680,7 @@ if wiredtiger: '$BUILD_DIR/mongo/db/commands/mongod_fcv', '$BUILD_DIR/mongo/db/commands/txn_cmd_request', '$BUILD_DIR/mongo/db/dbdirectclient', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/index_build_entry_helpers', '$BUILD_DIR/mongo/db/index_builds_coordinator_mongod', '$BUILD_DIR/mongo/db/logical_session_id_helpers', diff --git a/src/mongo/db/service_context_d_test_fixture.cpp b/src/mongo/db/service_context_d_test_fixture.cpp index 53debf67194..8903b5e1aa0 100644 --- a/src/mongo/db/service_context_d_test_fixture.cpp +++ b/src/mongo/db/service_context_d_test_fixture.cpp @@ -42,7 +42,6 @@ #include "mongo/db/catalog/database_holder_impl.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/global_settings.h" -#include "mongo/db/index/index_access_method_factory_impl.h" #include "mongo/db/index_builds_coordinator_mongod.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/repl/repl_settings.h" @@ -127,7 +126,6 @@ ServiceContextMongoDTest::ServiceContextMongoDTest(Options options) StorageControl::startStorageControls(serviceContext, true /*forTestOnly*/); DatabaseHolder::set(serviceContext, std::make_unique<DatabaseHolderImpl>()); - IndexAccessMethodFactory::set(serviceContext, std::make_unique<IndexAccessMethodFactoryImpl>()); Collection::Factory::set(serviceContext, std::make_unique<CollectionImpl::FactoryImpl>()); IndexBuildsCoordinator::set(serviceContext, std::make_unique<IndexBuildsCoordinatorMongod>()); CollectionShardingStateFactory::set( diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript index a35399610e0..2ee249b88cf 100644 --- a/src/mongo/db/storage/SConscript +++ b/src/mongo/db/storage/SConscript @@ -540,7 +540,7 @@ env.Library( '$BUILD_DIR/mongo/bson/util/bson_extract', '$BUILD_DIR/mongo/db/catalog/collection_catalog', '$BUILD_DIR/mongo/db/concurrency/lock_manager', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/index_names', '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/storage/bson_collection_catalog_entry', diff --git a/src/mongo/db/storage/ephemeral_for_test/SConscript b/src/mongo/db/storage/ephemeral_for_test/SConscript index 31c1331b557..0195d42ce8a 100644 --- a/src/mongo/db/storage/ephemeral_for_test/SConscript +++ b/src/mongo/db/storage/ephemeral_for_test/SConscript @@ -62,7 +62,7 @@ env.CppUnitTest( LIBDEPS=[ '$BUILD_DIR/mongo/db/auth/authmocks', '$BUILD_DIR/mongo/db/common', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/multitenancy', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/repl/replmocks', diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript index a76b6a9550c..9916a7f27c7 100644 --- a/src/mongo/db/storage/wiredtiger/SConscript +++ b/src/mongo/db/storage/wiredtiger/SConscript @@ -55,7 +55,7 @@ wtEnv.Library( '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/curop', '$BUILD_DIR/mongo/db/global_settings', - '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/prepare_conflict_tracker', '$BUILD_DIR/mongo/db/record_id_helpers', @@ -143,7 +143,7 @@ wtEnv.CppUnitTest( ], LIBDEPS=[ '$BUILD_DIR/mongo/db/auth/authmocks', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/db/repl/replmocks', '$BUILD_DIR/mongo/db/service_context', diff --git a/src/mongo/dbtests/SConscript b/src/mongo/dbtests/SConscript index 71aad61e5ce..418d4893655 100644 --- a/src/mongo/dbtests/SConscript +++ b/src/mongo/dbtests/SConscript @@ -32,8 +32,7 @@ env.Library( LIBDEPS=[ '$BUILD_DIR/mongo/db/catalog/catalog_impl', '$BUILD_DIR/mongo/db/dbdirectclient', - '$BUILD_DIR/mongo/db/index/index_access_method_factory', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/index_builds_coordinator_mongod', '$BUILD_DIR/mongo/db/op_observer', '$BUILD_DIR/mongo/db/service_context_d', @@ -148,7 +147,7 @@ env.Program( "$BUILD_DIR/mongo/db/commands/test_commands_enabled", "$BUILD_DIR/mongo/db/concurrency/deferred_writer", "$BUILD_DIR/mongo/db/exec/document_value/document_value_test_util", - "$BUILD_DIR/mongo/db/index/index_access_methods", + "$BUILD_DIR/mongo/db/index/index_access_method", "$BUILD_DIR/mongo/db/logical_time_metadata_hook", "$BUILD_DIR/mongo/db/mongohasher", "$BUILD_DIR/mongo/db/multitenancy", diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp index 330d796e9f3..27068cc571e 100644 --- a/src/mongo/dbtests/framework.cpp +++ b/src/mongo/dbtests/framework.cpp @@ -43,7 +43,6 @@ #include "mongo/db/client.h" #include "mongo/db/concurrency/lock_state.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/index/index_access_method_factory_impl.h" #include "mongo/db/index_builds_coordinator_mongod.h" #include "mongo/db/op_observer_registry.h" #include "mongo/db/s/collection_sharding_state_factory_shard.h" @@ -118,8 +117,6 @@ int runDbTests(int argc, char** argv) { StorageControl::startStorageControls(globalServiceContext, true /*forTestOnly*/); DatabaseHolder::set(globalServiceContext, std::make_unique<DatabaseHolderImpl>()); - IndexAccessMethodFactory::set(globalServiceContext, - std::make_unique<IndexAccessMethodFactoryImpl>()); Collection::Factory::set(globalServiceContext, std::make_unique<CollectionImpl::FactoryImpl>()); IndexBuildsCoordinator::set(globalServiceContext, std::make_unique<IndexBuildsCoordinatorMongod>()); diff --git a/src/mongo/embedded/SConscript b/src/mongo/embedded/SConscript index 879b5033969..c98aa087db4 100644 --- a/src/mongo/embedded/SConscript +++ b/src/mongo/embedded/SConscript @@ -88,8 +88,7 @@ env.Library( '$BUILD_DIR/mongo/db/commands/standalone', '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/fcv_op_observer', - '$BUILD_DIR/mongo/db/index/index_access_method_factory', - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/index_builds_coordinator_interface', '$BUILD_DIR/mongo/db/logical_session_cache', '$BUILD_DIR/mongo/db/logical_session_cache_impl', diff --git a/src/mongo/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp index 20395926254..f4cf1e382bc 100644 --- a/src/mongo/embedded/embedded.cpp +++ b/src/mongo/embedded/embedded.cpp @@ -47,7 +47,6 @@ #include "mongo/db/concurrency/lock_state.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/global_settings.h" -#include "mongo/db/index/index_access_method_factory_impl.h" #include "mongo/db/kill_sessions_local.h" #include "mongo/db/logical_session_cache_impl.h" #include "mongo/db/op_observer_impl.h" @@ -103,7 +102,6 @@ MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default")) void setUpCatalog(ServiceContext* serviceContext) { DatabaseHolder::set(serviceContext, std::make_unique<DatabaseHolderImpl>()); - IndexAccessMethodFactory::set(serviceContext, std::make_unique<IndexAccessMethodFactoryImpl>()); Collection::Factory::set(serviceContext, std::make_unique<CollectionImpl::FactoryImpl>()); } diff --git a/src/mongo/embedded/stitch_support/SConscript b/src/mongo/embedded/stitch_support/SConscript index 8ab94cb83c9..7206c33a1ce 100644 --- a/src/mongo/embedded/stitch_support/SConscript +++ b/src/mongo/embedded/stitch_support/SConscript @@ -43,7 +43,7 @@ stitchSupportTargets = stitchSupportEnv.Library( 'stitch_support.cpp', ], LIBDEPS_PRIVATE=[ - '$BUILD_DIR/mongo/db/index/index_access_methods', + '$BUILD_DIR/mongo/db/index/index_access_method', '$BUILD_DIR/mongo/db/matcher/expressions', '$BUILD_DIR/mongo/db/ops/parsed_update', '$BUILD_DIR/mongo/db/query/collation/collator_factory_icu', |