diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/s/flush_database_cache_updates_command.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/s/flush_database_cache_updates_command.cpp')
| -rw-r--r-- | src/mongo/db/s/flush_database_cache_updates_command.cpp | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/src/mongo/db/s/flush_database_cache_updates_command.cpp b/src/mongo/db/s/flush_database_cache_updates_command.cpp index 729572272f6..de95a293333 100644 --- a/src/mongo/db/s/flush_database_cache_updates_command.cpp +++ b/src/mongo/db/s/flush_database_cache_updates_command.cpp @@ -38,7 +38,6 @@ #include "mongo/db/catalog_raii.h" #include "mongo/db/client.h" #include "mongo/db/commands.h" -#include "mongo/db/dbdirectclient.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/s/database_sharding_state.h" @@ -53,29 +52,6 @@ namespace mongo { namespace { -/** - * Inserts a database collection entry with fixed metadata for the `config` or `admin` database. If - * the entry key already exists, it's not updated. - */ -Status insertDatabaseEntryForBackwardCompatibility(OperationContext* opCtx, - const StringData& dbName) { - invariant(dbName == NamespaceString::kAdminDb || dbName == NamespaceString::kConfigDb); - - DBDirectClient client(opCtx); - auto commandResponse = client.runCommand([&] { - auto dbMetadata = - DatabaseType(dbName.toString(), ShardId::kConfigServerId, DatabaseVersion::makeFixed()); - dbMetadata.setSharded(true); - - write_ops::InsertCommandRequest insertOp(NamespaceString::kShardConfigDatabasesNamespace); - insertOp.setDocuments({dbMetadata.toBSON()}); - return insertOp.serialize({}); - }()); - - auto commandStatus = getStatusFromWriteCommandReply(commandResponse->getCommandReply()); - return commandStatus.code() == ErrorCodes::DuplicateKey ? Status::OK() : commandStatus; -} - template <typename Derived> class FlushDatabaseCacheUpdatesCmdBase : public TypedCommand<Derived> { public: @@ -141,26 +117,6 @@ public: "Can't call _flushDatabaseCacheUpdates if in read-only mode", !storageGlobalParams.readOnly); - if (_dbName() == NamespaceString::kAdminDb || _dbName() == NamespaceString::kConfigDb) { - // The admin and config databases have fixed metadata that does not need to be - // refreshed. - - if (Base::request().getSyncFromConfig()) { - // To ensure compatibility with old secondaries that still call the - // _flushDatabaseCacheUpdates command to get updated database metadata from - // primary, an entry with fixed metadata is inserted in the - // config.cache.databases collection. - - LOGV2_DEBUG(6910800, - 1, - "Inserting a database collection entry with fixed metadata", - "db"_attr = _dbName()); - uassertStatusOK(insertDatabaseEntryForBackwardCompatibility(opCtx, _dbName())); - } - - return; - } - boost::optional<SharedSemiFuture<void>> criticalSectionSignal; { @@ -173,8 +129,8 @@ public: // consistency guarantee. const auto dss = DatabaseShardingState::get(opCtx, _dbName()); auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, dss); - criticalSectionSignal = dss->getCriticalSectionSignal( - ShardingMigrationCriticalSection::kWrite, dssLock); + criticalSectionSignal = + dss->getCriticalSectionSignal(ShardingMigrationCriticalSection::kRead, dssLock); } if (criticalSectionSignal) |
