summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/commands/set_feature_compatibility_version_command.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (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/commands/set_feature_compatibility_version_command.cpp')
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp90
1 files changed, 42 insertions, 48 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 7462b287ed8..73933d1abe2 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -84,7 +84,6 @@
#include "mongo/db/session_catalog.h"
#include "mongo/db/session_catalog_mongod.h"
#include "mongo/db/session_txn_record_gen.h"
-#include "mongo/db/storage/storage_parameters_gen.h"
#include "mongo/db/timeseries/timeseries_index_schema_conversion_functions.h"
#include "mongo/db/vector_clock.h"
#include "mongo/idl/cluster_server_parameter_gen.h"
@@ -466,7 +465,7 @@ public:
if (actualVersion > requestedVersion &&
!feature_flags::gOrphanTracking.isEnabledOnVersion(requestedVersion)) {
BalancerStatsRegistry::get(opCtx)->terminate();
- ScopedRangeDeleterLock rangeDeleterLock(opCtx, LockMode::MODE_X);
+ ScopedRangeDeleterLock rangeDeleterLock(opCtx);
clearOrphanCountersFromRangeDeletionTasks(opCtx);
}
@@ -631,6 +630,14 @@ private:
tenantDbName,
MODE_X,
[&](const CollectionPtr& collection) {
+ if (collection->getTimeseriesBucketsMayHaveMixedSchemaData()) {
+ // The catalog entry flag has already been added. This can happen if the
+ // upgrade process was interrupted and is being run again, or if there
+ // was a time-series collection created during the upgrade. The upgrade
+ // process cannot be aborted at this point.
+ return true;
+ }
+
NamespaceStringOrUUID nsOrUUID(dbName, collection->uuid());
CollMod collModCmd(collection->ns());
BSONObjBuilder unusedBuilder;
@@ -743,46 +750,16 @@ private:
const auto& dbName = tenantDbName.dbName();
Lock::DBLock dbLock(opCtx, dbName, MODE_IX);
catalog::forEachCollectionFromDb(
- opCtx, tenantDbName, MODE_X, [&](const CollectionPtr& collection) {
- const auto collNs = collection->getTimeseriesOptions()
- ? collection->ns().getTimeseriesViewNamespace()
- : collection->ns();
- auto indexCatalog = collection->getIndexCatalog();
+ opCtx,
+ tenantDbName,
+ MODE_X,
+ [&](const CollectionPtr& collection) {
+ invariant(collection->getTimeseriesOptions());
+ auto indexCatalog = collection->getIndexCatalog();
auto indexIt = indexCatalog->getIndexIterator(
- opCtx,
- IndexCatalog::InclusionPolicy::kReady |
- IndexCatalog::InclusionPolicy::kUnfinished |
- IndexCatalog::InclusionPolicy::kFrozen);
- while (indexIt->more()) {
- auto indexEntry = indexIt->next();
- if (auto filter = indexEntry->getFilterExpression()) {
- auto status = IndexCatalogImpl::checkValidFilterExpressions(
- filter,
- /*timeseriesMetricIndexesFeatureFlagEnabled*/ false);
- uassert(ErrorCodes::CannotDowngrade,
- str::stream()
- << "Cannot downgrade the cluster when there are "
- "secondary indexes with partial filter expressions "
- "that contain $in/$or/$geoWithin or an $and that is "
- "not top level. Drop all indexes containing these "
- "partial filter elements before downgrading. First "
- "detected incompatible index name: '"
- << indexEntry->descriptor()->indexName()
- << "' on collection: '" << collNs << "'",
- status.isOK());
- }
- }
+ opCtx, /*includeUnfinishedIndexes=*/true);
- if (!collection->getTimeseriesOptions()) {
- return true;
- }
-
- indexIt = indexCatalog->getIndexIterator(
- opCtx,
- IndexCatalog::InclusionPolicy::kReady |
- IndexCatalog::InclusionPolicy::kUnfinished |
- IndexCatalog::InclusionPolicy::kFrozen);
while (indexIt->more()) {
auto indexEntry = indexIt->next();
// Secondary indexes on time-series measurements are only supported
@@ -793,17 +770,34 @@ private:
ErrorCodes::CannotDowngrade,
str::stream()
<< "Cannot downgrade the cluster when there are secondary "
- "indexes on time-series measurements present, or when "
- "there are partial indexes on a time-series collection. "
- "Drop "
- "all secondary indexes on time-series measurements, and all "
+ "indexes on time-series measurements present, or when there "
+ "are partial indexes on a time-series collection. Drop all "
+ "secondary indexes on time-series measurements, and all "
"partial indexes on time-series collections, before "
"downgrading. First detected incompatible index name: '"
<< indexEntry->descriptor()->indexName() << "' on collection: '"
- << collNs << "'",
+ << collection->ns().getTimeseriesViewNamespace() << "'",
timeseries::isBucketsIndexSpecCompatibleForDowngrade(
*collection->getTimeseriesOptions(),
indexEntry->descriptor()->infoObj()));
+
+ if (auto filter = indexEntry->getFilterExpression()) {
+ auto status = IndexCatalogImpl::checkValidFilterExpressions(
+ filter,
+ /*timeseriesMetricIndexesFeatureFlagEnabled*/ false);
+ uassert(ErrorCodes::CannotDowngrade,
+ str::stream()
+ << "Cannot downgrade the cluster when there are "
+ "secondary indexes with partial filter expressions "
+ "that contain $in/$or/$geoWithin or an $and that is "
+ "not top level. Drop all indexes containing these "
+ "partial filter elements before downgrading. First "
+ "detected incompatible index name: '"
+ << indexEntry->descriptor()->indexName()
+ << "' on collection: '"
+ << collection->ns().getTimeseriesViewNamespace() << "'",
+ status.isOK());
+ }
}
if (!collection->getTimeseriesBucketsMayHaveMixedSchemaData()) {
@@ -830,6 +824,9 @@ private:
}
return true;
+ },
+ [&](const CollectionPtr& collection) {
+ return collection->getTimeseriesOptions() != boost::none;
});
}
}
@@ -871,10 +868,7 @@ private:
opCtx, tenantDbName, MODE_X, [&](const CollectionPtr& collection) {
auto indexCatalog = collection->getIndexCatalog();
auto indexIt = indexCatalog->getIndexIterator(
- opCtx,
- IndexCatalog::InclusionPolicy::kReady |
- IndexCatalog::InclusionPolicy::kUnfinished |
- IndexCatalog::InclusionPolicy::kFrozen);
+ opCtx, true /* includeUnfinishedIndexes */);
while (indexIt->more()) {
auto indexEntry = indexIt->next();
uassert(