summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMatt Boros <matt.boros@mongodb.com>2023-01-17 16:20:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-17 17:23:21 +0000
commit5e3d128c591c74669068e64452abddc5ba30d5b4 (patch)
tree7d00d5da6d2fd5183910ba9efc46eb44f5802bdf /src/mongo
parente45a27abe615d201e009a32ed31356aee75faffc (diff)
downloadmongo-5e3d128c591c74669068e64452abddc5ba30d5b4.tar.gz
SERVER-71068 Remove partial indexes FCV startup check
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp9
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp67
2 files changed, 41 insertions, 35 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 6be0b560bf9..24d7c85eea2 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -890,10 +890,11 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx,
}
const std::unique_ptr<MatchExpression> filterExpr = std::move(statusWithMatcher.getValue());
- Status status =
- _checkValidFilterExpressions(filterExpr.get(),
- feature_flags::gTimeseriesMetricIndexes.isEnabled(
- serverGlobalParams.featureCompatibility));
+ Status status = _checkValidFilterExpressions(
+ filterExpr.get(),
+ !serverGlobalParams.featureCompatibility.isVersionInitialized() ||
+ feature_flags::gTimeseriesMetricIndexes.isEnabled(
+ serverGlobalParams.featureCompatibility));
if (!status.isOK()) {
return status;
}
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 0c8f5a42c99..5e1b112f925 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"
@@ -750,37 +751,16 @@ 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);
-
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 +774,40 @@ 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,
+ /*includeUnfinishedIndexes=*/true);
+ 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 +832,6 @@ private:
}
return true;
- },
- [&](const CollectionPtr& collection) {
- return collection->getTimeseriesOptions() != boost::none;
});
}
}