diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2022-04-28 14:02:56 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-28 21:49:08 +0000 |
commit | 276fb7178679b295939ecf5709b10d4b75ad9d86 (patch) | |
tree | dad9b354fa46defc4e40567a75b2040d9dacaeb8 | |
parent | adc47cc974960abf0bc10a1b15234dc95ee6fdd4 (diff) | |
download | mongo-276fb7178679b295939ecf5709b10d4b75ad9d86.tar.gz |
SERVER-60912 Remove FCV references for time-series measurement indexes
-rw-r--r-- | jstests/noPassthrough/timeseries_upgrade_downgrade.js | 48 | ||||
-rw-r--r-- | src/mongo/db/catalog/coll_mod.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/commands/set_feature_compatibility_version_command.cpp | 132 | ||||
-rw-r--r-- | src/mongo/db/timeseries/bucket_catalog.cpp | 6 |
4 files changed, 0 insertions, 209 deletions
diff --git a/jstests/noPassthrough/timeseries_upgrade_downgrade.js b/jstests/noPassthrough/timeseries_upgrade_downgrade.js deleted file mode 100644 index eb66737588a..00000000000 --- a/jstests/noPassthrough/timeseries_upgrade_downgrade.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Tests that the upgrade process does not crash when time-series collections are created during the - * FCV upgrade process. - * - * TODO SERVER-60912: Remove this test once kLastLTS is 6.0. - */ -(function() { -"use strict"; - -load("jstests/core/timeseries/libs/timeseries.js"); -load("jstests/libs/fail_point_util.js"); - -const conn = MongoRunner.runMongod(); -const db = conn.getDB("test"); - -if (!TimeseriesTest.timeseriesMetricIndexesEnabled(db.getMongo())) { - jsTestLog( - "Skipped test as the featureFlagTimeseriesMetricIndexes feature flag is not enabled."); - MongoRunner.stopMongod(conn); - return; -} - -// Set FCV to 5.0. -assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -// Set fail point to fail the upgrade. -let upgradeFailPoint = configureFailPoint(conn, "failUpgrading"); - -// Start the upgrade, this will fail and we'll be in a semi-upgraded state. -assert.commandFailed(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -upgradeFailPoint.wait(); -upgradeFailPoint.off(); - -// Create a time-series collection while we're semi-upgraded. This time-series collection will have -// the 'timeseriesBucketsMayHaveMixedSchemaData' catalog entry flag set to false. -const collName = jsTestName(); -const coll = db.getCollection(collName); - -const timeFieldName = "tm"; -assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}})); - -// Re-try the upgrade after creating a time-series collection in a semi-upgraded state. This should -// not crash. -assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -MongoRunner.stopMongod(conn); -}()); diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 1924edfba19..7b35a04098c 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -928,29 +928,6 @@ Status _collModInternal(OperationContext* opCtx, opCtx, coll.getWritableCollection(opCtx), desc, CreateIndexEntryFlags::kIsReady); } - // (Generic FCV reference): TODO SERVER-60912: When kLastLTS is 6.0, remove this FCV-gated - // upgrade/downgrade code. - const auto currentVersion = serverGlobalParams.featureCompatibility.getVersion(); - if (coll->getTimeseriesOptions() && !coll->getTimeseriesBucketsMayHaveMixedSchemaData() && - (currentVersion == multiversion::GenericFCV::kUpgradingFromLastLTSToLatest || - currentVersion == multiversion::GenericFCV::kLatest)) { - // (Generic FCV reference): While upgrading the FCV from kLastLTS to kLatest, collMod is - // called as part of the upgrade process to add the - // 'timeseriesBucketsMayHaveMixedSchemaData=true' catalog entry flag for time-series - // collections that are missing the flag. This indicates that the time-series collection - // existed in earlier server versions and may have mixed-schema data. - coll.getWritableCollection(opCtx)->setTimeseriesBucketsMayHaveMixedSchemaData(opCtx, - true); - } else if (coll->getTimeseriesBucketsMayHaveMixedSchemaData() && - (currentVersion == multiversion::GenericFCV::kDowngradingFromLatestToLastLTS || - currentVersion == multiversion::GenericFCV::kLastLTS)) { - // (Generic FCV reference): While downgrading the FCV to kLastLTS, collMod is called as - // part of the downgrade process to remove the 'timeseriesBucketsMayHaveMixedSchemaData' - // catalog entry flag for time-series collections that have the flag. - coll.getWritableCollection(opCtx)->setTimeseriesBucketsMayHaveMixedSchemaData( - opCtx, boost::none); - } - // Only observe non-view collMods, as view operations are observed as operations on the // system.views collection. auto* const opObserver = opCtx->getServiceContext()->getOpObserver(); 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 59085d1e08a..75c9b98f024 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -555,50 +555,6 @@ private: Lock::GlobalLock lk(opCtx, MODE_S); } - // (Generic FCV reference): TODO SERVER-60912: When kLastLTS is 6.0, remove this FCV-gated - // upgrade code. - if (requestedVersion == multiversion::GenericFCV::kLatest) { - for (const auto& tenantDbName : DatabaseHolder::get(opCtx)->getNames()) { - const auto& dbName = tenantDbName.dbName(); - Lock::DBLock dbLock(opCtx, dbName, MODE_IX); - catalog::forEachCollectionFromDb( - opCtx, - 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; - Status status = - processCollModCommand(opCtx, nsOrUUID, collModCmd, &unusedBuilder); - - if (!status.isOK()) { - LOGV2_FATAL( - 6057503, - "Failed to add catalog entry during upgrade", - "error"_attr = status, - "timeseriesBucketsMayHaveMixedSchemaData"_attr = - collection->getTimeseriesBucketsMayHaveMixedSchemaData(), - logAttrs(collection->ns()), - logAttrs(collection->uuid())); - } - - return true; - }, - [&](const CollectionPtr& collection) { - return collection->getTimeseriesOptions() != boost::none; - }); - } - } - uassert(ErrorCodes::Error(549180), "Failing upgrade due to 'failUpgrading' failpoint set", !failUpgrading.shouldFail()); @@ -673,94 +629,6 @@ private: Lock::GlobalLock lk(opCtx, MODE_S); } - // (Generic FCV reference): TODO SERVER-60912: When kLastLTS is 6.0, remove this FCV-gated - // downgrade code. - if (requestedVersion == multiversion::GenericFCV::kLastLTS) { - for (const auto& tenantDbName : DatabaseHolder::get(opCtx)->getNames()) { - const auto& dbName = tenantDbName.dbName(); - Lock::DBLock dbLock(opCtx, dbName, MODE_IX); - catalog::forEachCollectionFromDb( - opCtx, - tenantDbName, - MODE_X, - [&](const CollectionPtr& collection) { - invariant(collection->getTimeseriesOptions()); - - 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, - /*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()) { - // The catalog entry flag has already been removed. This can happen if - // the downgrade process was interrupted and is being run again. The - // downgrade process cannot be aborted at this point. - return true; - } - NamespaceStringOrUUID nsOrUUID(dbName, collection->uuid()); - CollMod collModCmd(collection->ns()); - BSONObjBuilder unusedBuilder; - Status status = - processCollModCommand(opCtx, nsOrUUID, collModCmd, &unusedBuilder); - - if (!status.isOK()) { - LOGV2_FATAL( - 6057600, - "Failed to remove catalog entry during downgrade", - "error"_attr = status, - "timeseriesBucketsMayHaveMixedSchemaData"_attr = - collection->getTimeseriesBucketsMayHaveMixedSchemaData(), - logAttrs(collection->ns()), - logAttrs(collection->uuid())); - } - - return true; - }, - [&](const CollectionPtr& collection) { - return collection->getTimeseriesOptions() != boost::none; - }); - } - } - if (serverGlobalParams.featureCompatibility .isFCVDowngradingOrAlreadyDowngradedFromLatest()) { for (const auto& tenantDbName : DatabaseHolder::get(opCtx)->getNames()) { diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp index f2710fff960..c16da6175df 100644 --- a/src/mongo/db/timeseries/bucket_catalog.cpp +++ b/src/mongo/db/timeseries/bucket_catalog.cpp @@ -275,12 +275,6 @@ public: bool schemaIncompatible(const BSONObj& input, boost::optional<StringData> metaField, const StringData::ComparatorInterface* comparator) { - // (Generic FCV reference): TODO (SERVER-60912): Update once kLastLTS is 6.0 - if (serverGlobalParams.featureCompatibility.getVersion() == - multiversion::GenericFCV::kLastLTS) { - return false; - } - auto result = _schema.update(input, metaField, comparator); return (result == timeseries::Schema::UpdateStatus::Failed); } |