summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2021-06-16 11:18:52 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-16 19:48:15 +0000
commit9103cc7b17be65b107ab7c9d49ce111bb32654fc (patch)
tree9753779c82fb3755383b036ce8754cbf2a7f9fd8
parent0f4e555b24aa5441c078e58807c60796547a20cd (diff)
downloadmongo-9103cc7b17be65b107ab7c9d49ce111bb32654fc.tar.gz
SERVER-56268 Remove timeseriesBucketsCollectionClusterById server parameter
-rw-r--r--jstests/noPassthrough/timeseries_non_clustered_collmod.js52
-rw-r--r--jstests/noPassthrough/timeseries_server_parameters.js29
-rw-r--r--src/mongo/db/catalog/create_collection.cpp58
-rw-r--r--src/mongo/db/timeseries/timeseries.idl6
4 files changed, 7 insertions, 138 deletions
diff --git a/jstests/noPassthrough/timeseries_non_clustered_collmod.js b/jstests/noPassthrough/timeseries_non_clustered_collmod.js
deleted file mode 100644
index 2785ca4f436..00000000000
--- a/jstests/noPassthrough/timeseries_non_clustered_collmod.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Tests non-clustered time-series collections against collMod. Checks that changing
- * expireAfterSeconds on indexes is acceptable, but prevents changing the clustered
- * expireAfterSeconds option in the catalog.
- *
- * @tags: [
- * requires_fcv_49,
- * ]
- */
-(function() {
-"use strict";
-
-load("jstests/core/timeseries/libs/timeseries.js");
-
-// Disable clustering by _id on time-series collections.
-const conn = MongoRunner.runMongod({setParameter: 'timeseriesBucketsCollectionClusterById=false'});
-
-if (!TimeseriesTest.timeseriesCollectionsEnabled(conn)) {
- jsTestLog("Skipping test because the time-series collection feature flag is disabled");
- MongoRunner.stopMongod(conn);
- return;
-}
-
-const db = conn.getDB("test");
-const coll = db.timeseries_non_clustered_collmod;
-
-// Builds an index on control.min.time.
-const timeFieldName = 'time';
-const expireAfterSeconds = NumberLong(5);
-assert.commandWorked(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSeconds}));
-
-let indexes = assert.commandWorked(db.runCommand({listIndexes: coll.getName()})).cursor.firstBatch;
-assert.eq(1, indexes.length);
-assert.eq(indexes[0].key, {time: 1});
-
-// Changing expireAfterSeconds on control.min.time is acceptable.
-const bucketsColl = db.getCollection('system.buckets.' + coll.getName());
-assert.commandWorked(db.runCommand({
- collMod: bucketsColl.getName(),
- index: {keyPattern: {"control.min.time": 1}, expireAfterSeconds: NumberLong(20)}
-}));
-
-// Changing the clustered expireAfterSeconds option in the catalog can't happen on a non-clustered
-// time-series collection.
-assert.commandFailedWithCode(
- db.runCommand({collMod: coll.getName(), expireAfterSeconds: NumberLong(10)}),
- ErrorCodes.InvalidOptions);
-
-MongoRunner.stopMongod(conn);
-})(); \ No newline at end of file
diff --git a/jstests/noPassthrough/timeseries_server_parameters.js b/jstests/noPassthrough/timeseries_server_parameters.js
index 760ffd429a7..6365203d3e8 100644
--- a/jstests/noPassthrough/timeseries_server_parameters.js
+++ b/jstests/noPassthrough/timeseries_server_parameters.js
@@ -12,35 +12,6 @@
load("jstests/core/timeseries/libs/timeseries.js");
load("jstests/noPassthrough/libs/server_parameter_helpers.js");
-// Test that collection clustering can be disabled on the buckets collection, and that it behaves
-// correctly in a replicated environment.
-(() => {
- const replSet = new ReplSetTest({
- nodes: 2,
- nodeOptions: {setParameter: {timeseriesBucketsCollectionClusterById: false}},
- });
- replSet.startSet();
- replSet.initiate();
-
- const primary = replSet.getPrimary();
- if (!TimeseriesTest.timeseriesCollectionsEnabled(primary)) {
- jsTestLog("Skipping test case because time-series collections are not enabled.");
- replSet.stopSet();
- return;
- }
-
- const testDB = primary.getDB('test');
- assert.commandWorked(testDB.createCollection('ts', {timeseries: {timeField: 'time'}}));
- testDB.ts.insert({time: new Date()});
-
- let res = assert.commandWorked(
- testDB.runCommand({listCollections: 1, filter: {name: 'system.buckets.ts'}}));
- let options = res.cursor.firstBatch[0].options;
- assert(!options.clusteredIndex);
-
- replSet.stopSet();
-})();
-
// Valid parameter values are in the range [0, infinity).
testNumericServerParameter('timeseriesBucketMaxCount',
true /*isStartupParameter*/,
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index b59b23bb22d..baef2264ecd 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -225,33 +225,14 @@ Status _createTimeseries(OperationContext* opCtx,
CollectionOptions bucketsOptions = options;
bucketsOptions.validator = validatorObj;
- // If possible, cluster time-series buckets collections by _id.
- const bool useClusteredIdIndex = gTimeseriesBucketsCollectionClusterById;
+ // Cluster time-series buckets collections by _id.
auto expireAfterSeconds = options.expireAfterSeconds;
- if (useClusteredIdIndex) {
- if (expireAfterSeconds) {
- uassertStatusOK(
- index_key_validate::validateExpireAfterSeconds(*expireAfterSeconds));
- bucketsOptions.expireAfterSeconds = expireAfterSeconds;
- }
- bucketsOptions.clusteredIndex = true;
- }
-
- // Create a TTL index on 'control.min.[timeField]' if 'expireAfterSeconds' is provided
- // and the collection is not clustered by _id.
- BSONObj indexSpec;
- std::string indexName;
- if (expireAfterSeconds && !bucketsOptions.clusteredIndex) {
- const std::string controlMinTimeField = str::stream()
- << "control.min." << options.timeseries->getTimeField();
- indexName = controlMinTimeField + "_1";
- indexSpec =
- BSON(IndexDescriptor::kIndexVersionFieldName
- << IndexDescriptor::kLatestIndexVersion
- << IndexDescriptor::kKeyPatternFieldName << BSON(controlMinTimeField << 1)
- << IndexDescriptor::kIndexNameFieldName << indexName
- << IndexDescriptor::kExpireAfterSecondsFieldName << *expireAfterSeconds);
+ if (expireAfterSeconds) {
+ uassertStatusOK(
+ index_key_validate::validateExpireAfterSeconds(*expireAfterSeconds));
+ bucketsOptions.expireAfterSeconds = expireAfterSeconds;
}
+ bucketsOptions.clusteredIndex = true;
if (auto coll =
CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, bucketsNs)) {
@@ -260,39 +241,14 @@ Status _createTimeseries(OperationContext* opCtx,
existingBucketCollectionIsCompatible =
coll->getCollectionOptions().matchesStorageOptions(
bucketsOptions, CollatorFactoryInterface::get(opCtx->getServiceContext()));
- if (expireAfterSeconds && !bucketsOptions.clusteredIndex) {
- auto indexDescriptor =
- coll->getIndexCatalog()->findIndexByName(opCtx, indexName, true);
- existingBucketCollectionIsCompatible &=
- indexDescriptor && indexDescriptor->infoObj().woCompare(indexSpec) == 0;
- }
-
return Status(ErrorCodes::NamespaceExists,
str::stream() << "Bucket Collection already exists. NS: " << bucketsNs
<< ". UUID: " << coll->uuid());
}
// Create the buckets collection that will back the view.
- const bool createIdIndex = !useClusteredIdIndex;
+ const bool createIdIndex = false;
uassertStatusOK(db->userCreateNS(opCtx, bucketsNs, bucketsOptions, createIdIndex));
-
- // Create a TTL index if 'expireAfterSeconds' is provided and the collection is not
- // clustered by _id.
- if (expireAfterSeconds && !useClusteredIdIndex) {
- CollectionWriter collectionWriter(opCtx, bucketsNs);
- auto indexBuildCoord = IndexBuildsCoordinator::get(opCtx);
- auto fromMigrate = false;
- try {
- uassertStatusOK(index_key_validate::validateIndexSpecTTL(indexSpec));
- indexBuildCoord->createIndexesOnEmptyCollection(
- opCtx, collectionWriter, {indexSpec}, fromMigrate);
- } catch (DBException& ex) {
- ex.addContext(str::stream()
- << "failed to create TTL index on bucket collection: "
- << bucketsNs << "; index spec: " << indexSpec);
- return ex.toStatus();
- }
- }
wuow.commit();
return Status::OK();
});
diff --git a/src/mongo/db/timeseries/timeseries.idl b/src/mongo/db/timeseries/timeseries.idl
index 046e7652346..c97e9cf1887 100644
--- a/src/mongo/db/timeseries/timeseries.idl
+++ b/src/mongo/db/timeseries/timeseries.idl
@@ -54,12 +54,6 @@ server_parameters:
cpp_varname: "gTimeseriesIdleBucketExpiryMemoryUsageThreshold"
default: 104857600 # 100MB
validator: { gte: 1 }
- "timeseriesBucketsCollectionClusterById":
- description: "When true, newly-created time-series buckets collections are clustered by _id"
- set_at: [ startup ]
- cpp_vartype: bool
- cpp_varname: gTimeseriesBucketsCollectionClusterById
- default: true
enums:
BucketGranularity: