summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorAllison Easton <allison.easton@mongodb.com>2023-01-30 15:32:05 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-30 18:15:32 +0000
commit23b991e53a0eab64277dddc3fc2ced7d369e18ca (patch)
treece7a1b98e11b0ba65238fe1417b7f57b6e8be0ba /src/mongo
parentc4dd05cec97407b05249edc4d9ae45f81b0eb93d (diff)
downloadmongo-23b991e53a0eab64277dddc3fc2ced7d369e18ca.tar.gz
SERVER-70132 Handle FCV transitions for global indexes info
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index 0f17d001704..5edb138e3f1 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/dbhelpers.h"
#include "mongo/db/feature_compatibility_version_documentation.h"
#include "mongo/db/feature_compatibility_version_parser.h"
#include "mongo/db/global_settings.h"
@@ -767,6 +768,37 @@ private:
void _userCollectionsUassertsForDowngrade(
OperationContext* opCtx, const multiversion::FeatureCompatibilityVersion requestedVersion) {
if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) {
+ if (!feature_flags::gGlobalIndexesShardingCatalog.isEnabledOnVersion(
+ requestedVersion)) {
+ bool hasGlobalIndexes;
+ BSONObj indexDoc, collDoc;
+ {
+ AutoGetCollection indexesColl(
+ opCtx, NamespaceString::kConfigsvrIndexCatalogNamespace, MODE_IS);
+ hasGlobalIndexes =
+ Helpers::findOne(opCtx, indexesColl.getCollection(), BSONObj(), indexDoc);
+ }
+ if (hasGlobalIndexes) {
+ auto uuid = uassertStatusOK(
+ UUID::parse(indexDoc[IndexCatalogType::kCollectionUUIDFieldName]));
+ AutoGetCollection collsColl(
+ opCtx, NamespaceString::kConfigsvrCollectionsNamespace, MODE_IS);
+ Helpers::findOne(opCtx,
+ collsColl.getCollection(),
+ BSON(CollectionType::kUuidFieldName << uuid),
+ collDoc);
+ }
+ uassert(ErrorCodes::CannotDowngrade,
+ str::stream()
+ << "Cannot downgrade the cluster when there are global indexes "
+ "present. Drop all global indexes before downgrading. First "
+ "detected global index name: '"
+ << indexDoc[IndexCatalogType::kNameFieldName].String()
+ << "' on collection '"
+ << NamespaceString(collDoc[CollectionType::kNssFieldName].String())
+ << "'",
+ !hasGlobalIndexes);
+ }
return;
} else if (serverGlobalParams.clusterRole == ClusterRole::ShardServer ||
serverGlobalParams.clusterRole == ClusterRole::None) {