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-14 14:26:38 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-14 14:26:38 -0300
commit294bc6ecabf14c09c9bc8644704921dcf97cb44e (patch)
tree279b1e0bab53901a1647ac63c1c724f0f789a663 /src/mongo/db/commands/set_feature_compatibility_version_command.cpp
parent70be7c27a251621187a1de533462ae2bb1e3bd39 (diff)
parent1e917fd798aa25b7066d4b414b51184f13d5a092 (diff)
Update upstream source from tag 'upstream/6.0.10'debian/6.0.10-1
Update to upstream version '6.0.10' with Debian dir 2d176fa254eee97b139f712fec5709641335a8c3
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.cpp82
1 files changed, 48 insertions, 34 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 73933d1abe2..2c74781c36e 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -84,6 +84,7 @@
#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"
@@ -465,7 +466,7 @@ public:
if (actualVersion > requestedVersion &&
!feature_flags::gOrphanTracking.isEnabledOnVersion(requestedVersion)) {
BalancerStatsRegistry::get(opCtx)->terminate();
- ScopedRangeDeleterLock rangeDeleterLock(opCtx);
+ ScopedRangeDeleterLock rangeDeleterLock(opCtx, LockMode::MODE_X);
clearOrphanCountersFromRangeDeletionTasks(opCtx);
}
@@ -750,37 +751,19 @@ private:
const auto& dbName = tenantDbName.dbName();
Lock::DBLock dbLock(opCtx, dbName, MODE_IX);
catalog::forEachCollectionFromDb(
- opCtx,
- tenantDbName,
- MODE_X,
- [&](const CollectionPtr& collection) {
- invariant(collection->getTimeseriesOptions());
-
+ opCtx, tenantDbName, MODE_X, [&](const CollectionPtr& collection) {
+ const auto collNs = collection->getTimeseriesOptions()
+ ? collection->ns().getTimeseriesViewNamespace()
+ : collection->ns();
auto indexCatalog = collection->getIndexCatalog();
- auto indexIt = indexCatalog->getIndexIterator(
- opCtx, /*includeUnfinishedIndexes=*/true);
+ auto 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
- // in 5.2 and up. If the user tries to downgrade the cluster to an
- // earlier version, they must first remove all incompatible secondary
- // indexes on time-series measurements.
- uassert(
- 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 "
- "partial indexes on time-series collections, before "
- "downgrading. First detected incompatible index name: '"
- << indexEntry->descriptor()->indexName() << "' on collection: '"
- << collection->ns().getTimeseriesViewNamespace() << "'",
- timeseries::isBucketsIndexSpecCompatibleForDowngrade(
- *collection->getTimeseriesOptions(),
- indexEntry->descriptor()->infoObj()));
-
if (auto filter = indexEntry->getFilterExpression()) {
auto status = IndexCatalogImpl::checkValidFilterExpressions(
filter,
@@ -794,12 +777,43 @@ private:
"partial filter elements before downgrading. First "
"detected incompatible index name: '"
<< indexEntry->descriptor()->indexName()
- << "' on collection: '"
- << collection->ns().getTimeseriesViewNamespace() << "'",
+ << "' on collection: '" << collNs << "'",
status.isOK());
}
}
+ 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
+ // in 5.2 and up. If the user tries to downgrade the cluster to an
+ // earlier version, they must first remove all incompatible secondary
+ // indexes on time-series measurements.
+ uassert(
+ 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 "
+ "partial indexes on time-series collections, before "
+ "downgrading. First detected incompatible index name: '"
+ << indexEntry->descriptor()->indexName() << "' on collection: '"
+ << collNs << "'",
+ timeseries::isBucketsIndexSpecCompatibleForDowngrade(
+ *collection->getTimeseriesOptions(),
+ indexEntry->descriptor()->infoObj()));
+ }
+
if (!collection->getTimeseriesBucketsMayHaveMixedSchemaData()) {
// The catalog entry flag has already been removed. This can happen if
// the downgrade process was interrupted and is being run again. The
@@ -824,9 +838,6 @@ private:
}
return true;
- },
- [&](const CollectionPtr& collection) {
- return collection->getTimeseriesOptions() != boost::none;
});
}
}
@@ -868,7 +879,10 @@ private:
opCtx, tenantDbName, MODE_X, [&](const CollectionPtr& collection) {
auto indexCatalog = collection->getIndexCatalog();
auto indexIt = indexCatalog->getIndexIterator(
- opCtx, true /* includeUnfinishedIndexes */);
+ opCtx,
+ IndexCatalog::InclusionPolicy::kReady |
+ IndexCatalog::InclusionPolicy::kUnfinished |
+ IndexCatalog::InclusionPolicy::kFrozen);
while (indexIt->more()) {
auto indexEntry = indexIt->next();
uassert(