diff options
author | William Schultz <william.schultz@mongodb.com> | 2020-02-07 20:17:18 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-08 01:29:37 +0000 |
commit | 4ae67479e73174a75f2d7141360edb8a8ef90be8 (patch) | |
tree | 92a9ecc6a47e1dd201a8fc579700f74f0d8c8842 /src/mongo/db/s/shard_filtering_metadata_refresh.cpp | |
parent | 80321ac758befea3afd579572575ab91f6bb9e9e (diff) | |
download | mongo-4ae67479e73174a75f2d7141360edb8a8ef90be8.tar.gz |
Revert "SERVER-44771 Introduce 2nd CatalogCache for filtering only"
This reverts commit 3473d09fa9b5e418e119941b01c88863744689cc.
Diffstat (limited to 'src/mongo/db/s/shard_filtering_metadata_refresh.cpp')
-rw-r--r-- | src/mongo/db/s/shard_filtering_metadata_refresh.cpp | 77 |
1 files changed, 2 insertions, 75 deletions
diff --git a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp index 1c6ccc9f744..5926ddcb456 100644 --- a/src/mongo/db/s/shard_filtering_metadata_refresh.cpp +++ b/src/mongo/db/s/shard_filtering_metadata_refresh.cpp @@ -36,15 +36,12 @@ #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog_raii.h" #include "mongo/db/commands/feature_compatibility_version.h" -#include "mongo/db/commands/test_commands_enabled.h" #include "mongo/db/operation_context.h" #include "mongo/db/s/collection_sharding_runtime.h" #include "mongo/db/s/database_sharding_state.h" #include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/s/sharding_statistics.h" -#include "mongo/db/server_options.h" -#include "mongo/db/storage/storage_options.h" #include "mongo/s/catalog_cache.h" #include "mongo/s/grid.h" #include "mongo/util/fail_point.h" @@ -127,63 +124,8 @@ void onDbVersionMismatch(OperationContext* opCtx, forceDatabaseRefresh(opCtx, dbName); } -const auto catalogCacheForFilteringDecoration = - ServiceContext::declareDecoration<std::unique_ptr<CatalogCache>>(); - -const auto catalogCacheLoaderForFilteringDecoration = - ServiceContext::declareDecoration<std::unique_ptr<CatalogCacheLoader>>(); - -CatalogCache& getCatalogCacheForFiltering(ServiceContext* serviceContext) { - if (hasAdditionalCatalogCacheForFiltering()) { - auto& catalogCacheForFiltering = catalogCacheForFilteringDecoration(serviceContext); - invariant(catalogCacheForFiltering); - return *catalogCacheForFiltering; - } - return *Grid::get(serviceContext)->catalogCache(); -} - -CatalogCache& getCatalogCacheForFiltering(OperationContext* opCtx) { - return getCatalogCacheForFiltering(opCtx->getServiceContext()); -} - } // namespace - -bool hasAdditionalCatalogCacheForFiltering() { - invariant(serverGlobalParams.clusterRole == ClusterRole::ShardServer); - return getTestCommandsEnabled() && !storageGlobalParams.readOnly; -} - -void setCatalogCacheForFiltering(ServiceContext* serviceContext, - std::unique_ptr<CatalogCache> catalogCache) { - invariant(hasAdditionalCatalogCacheForFiltering()); - auto& catalogCacheForFiltering = catalogCacheForFilteringDecoration(serviceContext); - invariant(!catalogCacheForFiltering); - catalogCacheForFiltering = std::move(catalogCache); -} - -void setCatalogCacheLoaderForFiltering(ServiceContext* serviceContext, - std::unique_ptr<CatalogCacheLoader> loader) { - invariant(hasAdditionalCatalogCacheForFiltering()); - auto& catalogCacheLoader = catalogCacheLoaderForFilteringDecoration(serviceContext); - invariant(!catalogCacheLoader); - catalogCacheLoader = std::move(loader); -} - -CatalogCacheLoader& getCatalogCacheLoaderForFiltering(ServiceContext* serviceContext) { - if (hasAdditionalCatalogCacheForFiltering()) { - auto& catalogCacheLoader = catalogCacheLoaderForFilteringDecoration(serviceContext); - invariant(catalogCacheLoader); - return *catalogCacheLoader; - } - return CatalogCacheLoader::get(serviceContext); -} - -CatalogCacheLoader& getCatalogCacheLoaderForFiltering(OperationContext* opCtx) { - return getCatalogCacheLoaderForFiltering(opCtx->getServiceContext()); -} - - Status onShardVersionMismatchNoExcept(OperationContext* opCtx, const NamespaceString& nss, ChunkVersion shardVersionReceived, @@ -206,15 +148,8 @@ ChunkVersion forceShardFilteringMetadataRefresh(OperationContext* opCtx, auto* const shardingState = ShardingState::get(opCtx); invariant(shardingState->canAcceptShardedCommands()); - if (hasAdditionalCatalogCacheForFiltering()) { - Grid::get(opCtx) - ->catalogCache() - ->getCollectionRoutingInfoWithRefresh(opCtx, nss, forceRefreshFromThisThread) - .getStatus() - .ignore(); - } auto routingInfo = - uassertStatusOK(getCatalogCacheForFiltering(opCtx).getCollectionRoutingInfoWithRefresh( + uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfoWithRefresh( opCtx, nss, forceRefreshFromThisThread)); auto cm = routingInfo.cm(); @@ -305,16 +240,8 @@ void forceDatabaseRefresh(OperationContext* opCtx, const StringData dbName) { DatabaseVersion refreshedDbVersion; try { - if (hasAdditionalCatalogCacheForFiltering()) { - Grid::get(opCtx) - ->catalogCache() - ->getDatabaseWithRefresh(opCtx, dbName) - .getStatus() - .ignore(); - } refreshedDbVersion = - uassertStatusOK( - getCatalogCacheForFiltering(opCtx).getDatabaseWithRefresh(opCtx, dbName)) + uassertStatusOK(Grid::get(opCtx)->catalogCache()->getDatabaseWithRefresh(opCtx, dbName)) .databaseVersion(); } catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) { // db has been dropped, set the db version to boost::none |