SERVER-97326 Enable feature flag for the catalog cache split (featureFlagDualCatalogCache) (#54029)

Co-authored-by: Pol Piñol Castuera <pol.pinol@mongodb.com>
GitOrigin-RevId: 514a637c18bf55c22607c723b4d4e720211d927f
This commit is contained in:
Joan Bruguera Micó (at MongoDB) 2026-05-20 19:23:37 +00:00 committed by MongoDB Bot
parent 37c4a76c30
commit 14e3a4f28f
15 changed files with 64 additions and 339 deletions

View File

@ -5783,7 +5783,7 @@ class PipelineOptimizationsShardMerger : public PipelineOptimizations {
public:
void setUp() override {
PipelineOptimizations::setUp();
getCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(
getConfigServerCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(
DatabaseType{DatabaseName::createDatabaseName_forTest(boost::none, "a"),
kMyShardName,
DatabaseVersion{}});

View File

@ -1,132 +0,0 @@
/**
* 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/router_role/routing_cache/catalog_cache_loader_mock.h"
#include "mongo/base/error_codes.h"
#include "mongo/db/global_catalog/type_chunk.h"
#include "mongo/db/global_catalog/type_collection.h"
#include "mongo/db/global_catalog/type_collection_common_types_gen.h"
#include "mongo/db/keypattern.h"
#include "mongo/db/operation_context.h"
#include "mongo/util/assert_util.h"
#include <absl/container/node_hash_map.h>
#include <absl/meta/type_traits.h>
#include <boost/move/utility_core.hpp>
#include <boost/optional/optional.hpp>
namespace mongo {
using CollectionAndChangedChunks = CatalogCacheLoader::CollectionAndChangedChunks;
const Status CatalogCacheLoaderMock::kCollectionInternalErrorStatus = {
ErrorCodes::InternalError,
"Mocked catalog cache loader received unexpected collection request"};
const Status CatalogCacheLoaderMock::kChunksInternalErrorStatus = {
ErrorCodes::InternalError, "Mocked catalog cache loader received unexpected chunks request"};
const Status CatalogCacheLoaderMock::kDatabaseInternalErrorStatus = {
ErrorCodes::InternalError, "Mocked catalog cache loader received unexpected database request"};
void CatalogCacheLoaderMock::shutDown() {}
CollectionAndChangedChunks getCollectionRefresh(
const StatusWith<CollectionType>& swCollectionReturnValue,
StatusWith<std::vector<ChunkType>> swChunksReturnValue,
const boost::optional<TypeCollectionReshardingFields>& reshardingFields) {
uassertStatusOK(swCollectionReturnValue);
uassertStatusOK(swChunksReturnValue);
// We swap the chunks out of _swChunksReturnValue to ensure if this task is
// scheduled multiple times that we don't inform the ChunkManager about a chunk it
// has already updated.
std::vector<ChunkType> chunks;
swChunksReturnValue.getValue().swap(chunks);
return CollectionAndChangedChunks{swCollectionReturnValue.getValue().getEpoch(),
swCollectionReturnValue.getValue().getTimestamp(),
swCollectionReturnValue.getValue().getUuid(),
swCollectionReturnValue.getValue().getUnsplittable(),
swCollectionReturnValue.getValue().getKeyPattern().toBSON(),
swCollectionReturnValue.getValue().getDefaultCollation(),
swCollectionReturnValue.getValue().getUnique(),
swCollectionReturnValue.getValue().getTimeseriesFields(),
reshardingFields,
swCollectionReturnValue.getValue().getAllowMigrations(),
std::move(chunks)};
}
SemiFuture<CollectionAndChangedChunks> CatalogCacheLoaderMock::getChunksSince(
const NamespaceString& nss, ChunkVersion version) {
return makeReadyFutureWith([&nss, this] {
auto it = _refreshValues.find(nss);
if (it != _refreshValues.end())
return getCollectionRefresh(it->second.swCollectionReturnValue,
std::move(it->second.swChunksReturnValue),
it->second.reshardingFields);
return getCollectionRefresh(
_swCollectionReturnValue, std::move(_swChunksReturnValue), _reshardingFields);
})
.semi();
}
SemiFuture<DatabaseType> CatalogCacheLoaderMock::getDatabase(const DatabaseName& dbName) {
return makeReadyFutureWith([this] { return _swDatabaseReturnValue; }).semi();
}
void CatalogCacheLoaderMock::setCollectionRefreshReturnValue(
StatusWith<CollectionType> statusWithCollectionType) {
_swCollectionReturnValue = std::move(statusWithCollectionType);
}
void CatalogCacheLoaderMock::clearCollectionReturnValue() {
_swCollectionReturnValue = kCollectionInternalErrorStatus;
}
void CatalogCacheLoaderMock::setChunkRefreshReturnValue(
StatusWith<std::vector<ChunkType>> statusWithChunks) {
_swChunksReturnValue = std::move(statusWithChunks);
}
void CatalogCacheLoaderMock::clearChunksReturnValue() {
_swChunksReturnValue = kChunksInternalErrorStatus;
}
void CatalogCacheLoaderMock::setDatabaseRefreshReturnValue(StatusWith<DatabaseType> swDatabase) {
_swDatabaseReturnValue = std::move(swDatabase);
}
void CatalogCacheLoaderMock::clearDatabaseReturnValue() {
_swDatabaseReturnValue = kDatabaseInternalErrorStatus;
}
} // namespace mongo

View File

@ -1,126 +0,0 @@
/**
* 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.
*/
#pragma once
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/db/global_catalog/type_chunk.h"
#include "mongo/db/global_catalog/type_collection.h"
#include "mongo/db/global_catalog/type_database_gen.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/router_role/routing_cache/catalog_cache_loader.h"
#include "mongo/db/versioning_protocol/chunk_version.h"
#include "mongo/s/resharding/type_collection_fields_gen.h"
#include "mongo/stdx/unordered_map.h"
#include "mongo/util/future.h"
#include "mongo/util/modules.h"
#include <utility>
#include <vector>
#include <absl/container/node_hash_map.h>
#include <boost/optional/optional.hpp>
namespace mongo {
/**
* Mocks the metadata refresh results with settable return values. The purpose of this class is to
* facilitate testing of classes that use a CatalogCacheLoader.
*/
class MONGO_MOD_PARENT_PRIVATE CatalogCacheLoaderMock final : public CatalogCacheLoader {
CatalogCacheLoaderMock(const CatalogCacheLoaderMock&) = delete;
CatalogCacheLoaderMock& operator=(const CatalogCacheLoaderMock&) = delete;
public:
CatalogCacheLoaderMock() = default;
~CatalogCacheLoaderMock() override = default;
void shutDown() override;
SemiFuture<CollectionAndChangedChunks> getChunksSince(const NamespaceString& nss,
ChunkVersion version) override;
SemiFuture<DatabaseType> getDatabase(const DatabaseName& dbName) override;
/**
* Sets the mocked collection entry result that getChunksSince will use to construct its return
* value.
*/
void setCollectionRefreshReturnValue(StatusWith<CollectionType> statusWithCollectionType);
void clearCollectionReturnValue();
/**
* Sets the mocked chunk results that getChunksSince will use to construct its return value.
*/
void setChunkRefreshReturnValue(StatusWith<std::vector<ChunkType>> statusWithChunks);
void clearChunksReturnValue();
/**
* Sets the mocked database entry result that getDatabase will use to construct its return
* value.
*/
void setDatabaseRefreshReturnValue(StatusWith<DatabaseType> swDatabase);
void clearDatabaseReturnValue();
void setReshardingFields(boost::optional<TypeCollectionReshardingFields> reshardingFields) {
_reshardingFields = std::move(reshardingFields);
}
void setCollectionRefreshValues(
const NamespaceString& nss,
StatusWith<CollectionType> statusWithCollection,
StatusWith<std::vector<ChunkType>> statusWithChunks,
boost::optional<TypeCollectionReshardingFields> reshardingFields) {
_refreshValues[nss] = {statusWithCollection, statusWithChunks, reshardingFields};
}
static const Status kCollectionInternalErrorStatus;
static const Status kChunksInternalErrorStatus;
static const Status kDatabaseInternalErrorStatus;
private:
StatusWith<CollectionType> _swCollectionReturnValue{kCollectionInternalErrorStatus};
StatusWith<std::vector<ChunkType>> _swChunksReturnValue{kChunksInternalErrorStatus};
boost::optional<TypeCollectionReshardingFields> _reshardingFields;
struct RefreshInfo {
StatusWith<CollectionType> swCollectionReturnValue{kCollectionInternalErrorStatus};
StatusWith<std::vector<ChunkType>> swChunksReturnValue{kChunksInternalErrorStatus};
boost::optional<TypeCollectionReshardingFields> reshardingFields;
};
stdx::unordered_map<NamespaceString, RefreshInfo> _refreshValues;
StatusWith<DatabaseType> _swDatabaseReturnValue{kDatabaseInternalErrorStatus};
};
} // namespace mongo

View File

@ -46,7 +46,7 @@
#include "mongo/db/query/client_cursor/cursor_id.h"
#include "mongo/db/query/client_cursor/cursor_response.h"
#include "mongo/db/router_role/routing_cache/catalog_cache.h"
#include "mongo/db/router_role/routing_cache/catalog_cache_loader_mock.h"
#include "mongo/db/router_role/routing_cache/config_server_catalog_cache_loader_mock.h"
#include "mongo/db/router_role/routing_cache/shard_cannot_refresh_due_to_locks_held_exception.h"
#include "mongo/db/sharding_environment/sharding_mongos_test_fixture.h"
#include "mongo/db/timeseries/timeseries_gen.h"
@ -85,7 +85,7 @@ protected:
configTargeter()->setFindHostReturnValue(kConfigHostAndPort);
// Setup catalogCache with mock loader
_catalogCacheLoader = std::make_shared<CatalogCacheLoaderMock>();
_catalogCacheLoader = std::make_shared<ConfigServerCatalogCacheLoaderMock>();
_catalogCache = std::make_unique<CatalogCache>(getServiceContext(), _catalogCacheLoader);
// Populate the shardRegistry with the shards from kShards vector
@ -99,8 +99,9 @@ protected:
class ScopedCollectionProvider {
public:
ScopedCollectionProvider(std::shared_ptr<CatalogCacheLoaderMock> catalogCacheLoader,
const StatusWith<CollectionType>& swCollection)
ScopedCollectionProvider(
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> catalogCacheLoader,
const StatusWith<CollectionType>& swCollection)
: _catalogCacheLoader(catalogCacheLoader) {
_catalogCacheLoader->setCollectionRefreshReturnValue(swCollection);
}
@ -109,7 +110,7 @@ protected:
}
private:
std::shared_ptr<CatalogCacheLoaderMock> _catalogCacheLoader;
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> _catalogCacheLoader;
};
ScopedCollectionProvider scopedCollectionProvider(
@ -119,7 +120,7 @@ protected:
class ScopedChunksProvider {
public:
ScopedChunksProvider(std::shared_ptr<CatalogCacheLoaderMock> catalogCacheLoader,
ScopedChunksProvider(std::shared_ptr<ConfigServerCatalogCacheLoaderMock> catalogCacheLoader,
const StatusWith<std::vector<ChunkType>>& swChunks)
: _catalogCacheLoader(catalogCacheLoader) {
_catalogCacheLoader->setChunkRefreshReturnValue(swChunks);
@ -129,7 +130,7 @@ protected:
}
private:
std::shared_ptr<CatalogCacheLoaderMock> _catalogCacheLoader;
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> _catalogCacheLoader;
};
ScopedChunksProvider scopedChunksProvider(const StatusWith<std::vector<ChunkType>>& swChunks) {
@ -138,8 +139,9 @@ protected:
class ScopedDatabaseProvider {
public:
ScopedDatabaseProvider(std::shared_ptr<CatalogCacheLoaderMock> catalogCacheLoader,
const StatusWith<DatabaseType>& swDatabase)
ScopedDatabaseProvider(
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> catalogCacheLoader,
const StatusWith<DatabaseType>& swDatabase)
: _catalogCacheLoader(catalogCacheLoader) {
_catalogCacheLoader->setDatabaseRefreshReturnValue(swDatabase);
}
@ -148,7 +150,7 @@ protected:
}
private:
std::shared_ptr<CatalogCacheLoaderMock> _catalogCacheLoader;
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> _catalogCacheLoader;
};
ScopedDatabaseProvider scopedDatabaseProvider(const StatusWith<DatabaseType>& swDatabase) {
@ -210,7 +212,7 @@ protected:
const HostAndPort kConfigHostAndPort{"DummyConfig", kDummyPort};
const std::vector<ShardId> kShards{{"0"}, {"1"}};
std::shared_ptr<CatalogCacheLoaderMock> _catalogCacheLoader;
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> _catalogCacheLoader;
std::unique_ptr<CatalogCache> _catalogCache;
};

View File

@ -62,8 +62,6 @@
#include "mongo/db/repl/replication_coordinator_mock.h"
#include "mongo/db/repl/wait_for_majority_service.h"
#include "mongo/db/router_role/routing_cache/catalog_cache.h"
#include "mongo/db/router_role/routing_cache/catalog_cache_loader.h"
#include "mongo/db/router_role/routing_cache/catalog_cache_loader_mock.h"
#include "mongo/db/router_role/routing_cache/shard_cannot_refresh_due_to_locks_held_exception.h"
#include "mongo/db/s/resharding/local_resharding_operations_registry.h"
#include "mongo/db/s/resharding/sharding_write_router.h"
@ -301,28 +299,28 @@ protected:
BSON(kShardKey << 1));
coll.setAllowMigrations(false);
// When running in transaction, the db version must carry a PlacementConflictTime.
const auto chunksWithXShardKey = createChunks(env.version.placementVersion().epoch(),
env.sourceUuid,
env.version.placementVersion().getTimestamp(),
kShardKey);
const auto chunksWithYShardKey = createChunks(env.version.placementVersion().epoch(),
env.sourceUuid,
env.version.placementVersion().getTimestamp(),
"y");
getShardServerCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(
DatabaseType(kNss.dbName(), kShardList[0].getName(), env.dbVersion));
getShardServerCatalogCacheLoaderMock()->setCollectionRefreshValues(
kNss, coll, chunksWithXShardKey, reshardingFields);
getShardServerCatalogCacheLoaderMock()->setCollectionRefreshValues(
env.tempNss, coll, chunksWithYShardKey, boost::none);
getConfigServerCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(
DatabaseType(kNss.dbName(), kShardList[0].getName(), env.dbVersion));
getCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(
DatabaseType(kNss.dbName(), kShardList[0].getName(), env.dbVersion));
getCatalogCacheLoaderMock()->setCollectionRefreshValues(
kNss,
coll,
createChunks(env.version.placementVersion().epoch(),
env.sourceUuid,
env.version.placementVersion().getTimestamp(),
kShardKey),
reshardingFields);
getCatalogCacheLoaderMock()->setCollectionRefreshValues(
env.tempNss,
coll,
createChunks(env.version.placementVersion().epoch(),
env.sourceUuid,
env.version.placementVersion().getTimestamp(),
"y"),
boost::none);
getConfigServerCatalogCacheLoaderMock()->setCollectionRefreshValues(
kNss, coll, chunksWithXShardKey, reshardingFields);
getConfigServerCatalogCacheLoaderMock()->setCollectionRefreshValues(
env.tempNss, coll, chunksWithYShardKey, boost::none);
// Refresh the filtering metadata for the nss.
ASSERT_OK(FilteringMetadataCache::get(opCtx)->forceDatabaseMetadataRefresh_DEPRECATED(

View File

@ -182,11 +182,7 @@ public:
_mockConfigServerCacheLoader = std::make_shared<ConfigServerCatalogCacheLoaderMock>();
_mockShardServerCacheLoader = std::make_shared<ShardServerCatalogCacheLoaderMock>();
auto catalogCache =
std::make_unique<CatalogCache>(getServiceContext(),
_mockConfigServerCacheLoader,
_mockShardServerCacheLoader,
true /* cascadeDatabaseCacheLoaderShutdown */,
false /* cascadeCollectionCacheLoaderShutdown */);
std::make_unique<CatalogCache>(getServiceContext(), _mockConfigServerCacheLoader);
uassertStatusOK(
initializeGlobalShardingStateForMongodForTest(ConnectionString(kConfigHostAndPort),
std::move(catalogCache),

View File

@ -71,8 +71,6 @@
#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/repl/storage_interface_impl.h"
#include "mongo/db/repl/wait_for_majority_service.h"
#include "mongo/db/router_role/routing_cache/catalog_cache_loader.h"
#include "mongo/db/router_role/routing_cache/catalog_cache_loader_mock.h"
#include "mongo/db/s/resharding/resharding_txn_cloner_progress_gen.h"
#include "mongo/db/server_options.h"
#include "mongo/db/service_context.h"
@ -145,11 +143,11 @@ class ReshardingTxnClonerTest : service_context_test::WithSetupTransportLayer,
ShardServerTestFixtureWithCatalogCacheLoaderMock::setUp();
// The config database's primary shard is always config, and it is always sharded.
getCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(DatabaseType{
getConfigServerCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(DatabaseType{
DatabaseName::kConfig, ShardId::kConfigServerId, DatabaseVersion::makeFixed()});
// The config.transactions collection is always unsharded.
getCatalogCacheLoaderMock()->setCollectionRefreshReturnValue(
getConfigServerCatalogCacheLoaderMock()->setCollectionRefreshReturnValue(
{ErrorCodes::NamespaceNotFound, "collection not found"});
for (const auto& shardId : kTwoShardIdList) {

View File

@ -222,7 +222,7 @@ TEST_F(DatabaseShardingRuntimeTestWithMockedLoader, ForceDatabaseRefresh) {
const auto newDbVersion = newDb.getVersion();
auto opCtx = operationContext();
getCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(newDb);
getShardServerCatalogCacheLoaderMock()->setDatabaseRefreshReturnValue(newDb);
ASSERT_OK(FilteringMetadataCache::get(opCtx)->forceDatabaseMetadataRefresh_DEPRECATED(
opCtx, kDbName));

View File

@ -152,7 +152,6 @@ mongo_cc_library(
name = "sharding_test_fixture_common",
srcs = [
"sharding_test_fixture_common.cpp",
"//src/mongo/db/router_role/routing_cache:catalog_cache_loader_mock.cpp",
"//src/mongo/db/router_role/routing_cache:catalog_cache_mock.cpp",
"//src/mongo/db/router_role/routing_cache:config_server_catalog_cache_loader_mock.cpp",
"//src/mongo/db/router_role/routing_cache:shard_server_catalog_cache_loader_mock.cpp",

View File

@ -130,19 +130,17 @@ void ConfigServerTestFixture::setUp() {
_addShardNetworkTestEnv =
std::make_unique<NetworkTestEnv>(_executorForAddShard, _mockNetworkForAddShard);
auto loader = std::make_shared<ShardServerCatalogCacheLoaderImpl>(
std::make_unique<ConfigServerCatalogCacheLoaderImpl>());
auto routerLoader = std::make_shared<ConfigServerCatalogCacheLoaderImpl>();
auto catalogCache =
std::make_unique<CatalogCache>(getServiceContext(),
std::make_unique<ConfigServerCatalogCacheLoaderImpl>(),
loader,
true /* cascadeDatabaseCacheLoaderShutdown */,
false /* cascadeCollectionCacheLoaderShutdown */);
RoutingInformationCache::set(getServiceContext());
std::make_unique<CatalogCache>(getServiceContext(), std::move(routerLoader));
auto shardLoader = std::make_shared<ShardServerCatalogCacheLoaderImpl>(
std::make_unique<ConfigServerCatalogCacheLoaderImpl>());
uassertStatusOK(initializeGlobalShardingStateForMongodForTest(
ConnectionString::forLocal(), std::move(catalogCache), std::move(loader)));
ConnectionString::forLocal(), std::move(catalogCache), std::move(shardLoader)));
RoutingInformationCache::setOverride(getServiceContext(),
Grid::get(getServiceContext())->catalogCache());
auto shardLocal = Grid::get(getServiceContext())->shardRegistry()->createLocalConfigShard();
ASSERT_EQ(typeid(*shardLocal).name(), typeid(ConfigShardWrapper).name());

View File

@ -82,11 +82,7 @@ void ShardServerTestFixture::setUp() {
if (!_catalogCache) {
_catalogCache =
std::make_unique<CatalogCache>(getServiceContext(),
_configServerCatalogCacheLoader,
_shardServerCatalogCacheLoader,
true /* cascadeDatabaseCacheLoaderShutdown */,
false /* cascadeCollectionCacheLoaderShutdown */);
std::make_unique<CatalogCache>(getServiceContext(), _configServerCatalogCacheLoader);
}
uassertStatusOK(
@ -121,8 +117,8 @@ std::unique_ptr<ShardingCatalogClient> ShardServerTestFixture::makeShardingCatal
}
void ShardServerTestFixtureWithCatalogCacheMock::setUp() {
auto loader = std::make_shared<ShardServerCatalogCacheLoaderMock>();
setShardServerCatalogCacheLoader(loader);
auto loader = std::make_shared<ConfigServerCatalogCacheLoaderMock>();
setConfigServerCatalogCacheLoader(loader);
setCatalogCache(std::make_unique<CatalogCacheMock>(getServiceContext(), std::move(loader)));
ShardServerTestFixture::setUp();
}
@ -131,10 +127,10 @@ CatalogCacheMock* ShardServerTestFixtureWithCatalogCacheMock::getCatalogCacheMoc
return static_cast<CatalogCacheMock*>(catalogCache());
}
std::shared_ptr<ShardServerCatalogCacheLoaderMock>
ShardServerTestFixtureWithCatalogCacheMock::getCatalogCacheLoaderMock() {
auto mockLoader = std::dynamic_pointer_cast<ShardServerCatalogCacheLoaderMock>(
_shardServerCatalogCacheLoader);
std::shared_ptr<ConfigServerCatalogCacheLoaderMock>
ShardServerTestFixtureWithCatalogCacheMock::getConfigServerCatalogCacheLoaderMock() {
auto mockLoader = std::dynamic_pointer_cast<ConfigServerCatalogCacheLoaderMock>(
_configServerCatalogCacheLoader);
invariant(mockLoader);
return mockLoader;
}
@ -162,7 +158,7 @@ ShardServerTestFixtureWithCatalogCacheLoaderMock::getConfigServerCatalogCacheLoa
}
std::shared_ptr<ShardServerCatalogCacheLoaderMock>
ShardServerTestFixtureWithCatalogCacheLoaderMock::getCatalogCacheLoaderMock() {
ShardServerTestFixtureWithCatalogCacheLoaderMock::getShardServerCatalogCacheLoaderMock() {
auto mockLoader = std::dynamic_pointer_cast<ShardServerCatalogCacheLoaderMock>(
_shardServerCatalogCacheLoader);
invariant(mockLoader);

View File

@ -106,7 +106,7 @@ public:
protected:
void setUp() override;
CatalogCacheMock* getCatalogCacheMock();
std::shared_ptr<ShardServerCatalogCacheLoaderMock> getCatalogCacheLoaderMock();
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> getConfigServerCatalogCacheLoaderMock();
};
class MONGO_MOD_OPEN ShardServerTestFixtureWithCatalogCacheLoaderMock
@ -115,7 +115,7 @@ protected:
void setUp() override;
CatalogCacheMock* getCatalogCacheMock();
std::shared_ptr<ConfigServerCatalogCacheLoaderMock> getConfigServerCatalogCacheLoaderMock();
std::shared_ptr<ShardServerCatalogCacheLoaderMock> getCatalogCacheLoaderMock();
std::shared_ptr<ShardServerCatalogCacheLoaderMock> getShardServerCatalogCacheLoaderMock();
};
} // namespace mongo

View File

@ -115,7 +115,7 @@ feature_flags:
"Feature flag to enable one catalog cache for the shard role and another one for
the router role."
cpp_varname: feature_flags::gDualCatalogCache
default: false
default: true
fcv_gated: false
featureFlagUseTopologyChangeCoordinators:
description: "Feature flag for enabling the coordinator based topology changes."

View File

@ -84,17 +84,14 @@ protected:
[&](OperationContext* opCtx, const ShardIdentity& shardIdentity) {
const auto& configConnStr = shardIdentity.getConfigsvrConnectionString();
auto loader = std::make_shared<ShardServerCatalogCacheLoaderImpl>(
std::make_unique<ConfigServerCatalogCacheLoaderImpl>());
auto catalogCache = std::make_unique<CatalogCache>(
opCtx->getServiceContext(),
std::make_unique<ConfigServerCatalogCacheLoaderImpl>(),
loader,
true /* cascadeDatabaseCacheLoaderShutdown */,
false /* cascadeCollectionCacheLoaderShutdown */);
auto routerLoader = std::make_shared<ConfigServerCatalogCacheLoaderImpl>();
auto catalogCache = std::make_unique<CatalogCache>(opCtx->getServiceContext(),
std::move(routerLoader));
auto shardLoader = std::make_shared<ShardServerCatalogCacheLoaderImpl>(
std::make_unique<ConfigServerCatalogCacheLoaderImpl>());
uassertStatusOK(initializeGlobalShardingStateForMongodForTest(
configConnStr, std::move(catalogCache), std::move(loader)));
configConnStr, std::move(catalogCache), std::move(shardLoader)));
// Set the ConnectionString return value on the mock targeter so that later
// calls to the targeter's getConnString() return the appropriate value

View File

@ -299,11 +299,10 @@ void ShardingMongoDTestFixture::tearDown() {
}
}
FilteringMetadataCache::get(getServiceContext())->clearForUnitTests();
CollectionShardingStateFactory::clear(getServiceContext());
DatabaseShardingStateFactory::clear(getServiceContext());
Grid::get(operationContext())->clearForUnitTests();
FilteringMetadataCache::get(getServiceContext())->clearForUnitTests();
ShardingTestFixtureCommon::tearDown();
}