summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Tuckman <ted.tuckman@mongodb.com>2021-10-05 13:41:45 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-05 15:01:05 +0000
commitd6790e0ebc3a484a83e107536940d11780460d6f (patch)
treee1268533300eef19ed7228ffbaaba3f27d0035f6
parent0d18dab404e4649c054666e5787000154c7e42c0 (diff)
downloadmongo-d6790e0ebc3a484a83e107536940d11780460d6f.tar.gz
SERVER-52290 Remove featureFlagDensify
-rw-r--r--jstests/aggregation/sources/densify/decimal.js9
-rw-r--r--jstests/aggregation/sources/densify/desugar.js56
-rw-r--r--jstests/aggregation/sources/densify/explicit_range.js9
-rw-r--r--jstests/aggregation/sources/densify/full_range.js9
-rw-r--r--jstests/aggregation/sources/densify/generated_limit.js7
-rw-r--r--jstests/aggregation/sources/densify/libs/densify_in_js.js8
-rw-r--r--jstests/aggregation/sources/densify/libs/parse_util.js23
-rw-r--r--jstests/aggregation/sources/densify/memory_limit.js7
-rw-r--r--jstests/aggregation/sources/densify/partitions.js59
-rw-r--r--src/mongo/db/pipeline/document_source_densify.cpp30
-rw-r--r--src/mongo/db/pipeline/document_source_densify_test.cpp17
-rw-r--r--src/mongo/db/query/query_feature_flags.idl5
12 files changed, 84 insertions, 155 deletions
diff --git a/jstests/aggregation/sources/densify/decimal.js b/jstests/aggregation/sources/densify/decimal.js
index 4c8b423f38b..415cd3117b3 100644
--- a/jstests/aggregation/sources/densify/decimal.js
+++ b/jstests/aggregation/sources/densify/decimal.js
@@ -10,14 +10,6 @@
load("jstests/aggregation/extras/utils.js"); // For arrayEq.
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
-
function buildErrorString(found, expected) {
return "Expected:\n" + tojson(expected) + "\nGot:\n" + tojson(found);
}
@@ -94,6 +86,7 @@ expectedResult = [
{val: .7},
{val: .7999999999999999},
{val: .8999999999999999},
+ {val: .9999999999999999},
{val: NumberDecimal(1)},
];
result = coll.aggregate(pipeline).toArray();
diff --git a/jstests/aggregation/sources/densify/desugar.js b/jstests/aggregation/sources/densify/desugar.js
index b1f7c11154d..0d89abd3feb 100644
--- a/jstests/aggregation/sources/densify/desugar.js
+++ b/jstests/aggregation/sources/densify/desugar.js
@@ -11,14 +11,6 @@
(function() {
"use strict";
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
-
load("jstests/libs/fixture_helpers.js");
const coll = db[jsTestName()];
@@ -114,27 +106,29 @@ assert.eq(
]);
// PartitionByFields are prepended to the sortKey if date bounds are specified.
-assert.eq(
- desugar({
- $densify: {
- field: "a",
- partitionByFields: ["b", "c"],
- range:
- {step: 1.0, bounds: [new Date("2020-01-03"), new Date("2020-01-04")], unit: "day"}
- }
- }),
- [
- {$sort: {sortKey: {b: 1, c: 1, a: 1}}},
- {
- $_internalDensify: {
- field: "a",
- partitionByFields: ["b", "c"],
- range: {
- step: 1.0,
- bounds: [new Date("2020-01-03"), new Date("2020-01-04")],
- unit: "day"
- }
- }
- },
- ]);
+assert.eq(desugar({
+ $densify: {
+ field: "a",
+ partitionByFields: ["b", "c"],
+ range: {
+ step: 1.0,
+ bounds: [new ISODate("2020-01-03"), new ISODate("2020-01-04")],
+ unit: "day"
+ }
+ }
+ }),
+ [
+ {$sort: {sortKey: {b: 1, c: 1, a: 1}}},
+ {
+ $_internalDensify: {
+ field: "a",
+ partitionByFields: ["b", "c"],
+ range: {
+ step: 1.0,
+ bounds: [new ISODate("2020-01-03"), new ISODate("2020-01-04")],
+ unit: "day"
+ }
+ }
+ },
+ ]);
})();
diff --git a/jstests/aggregation/sources/densify/explicit_range.js b/jstests/aggregation/sources/densify/explicit_range.js
index 6f7e2d3d3cd..842ae79d5bf 100644
--- a/jstests/aggregation/sources/densify/explicit_range.js
+++ b/jstests/aggregation/sources/densify/explicit_range.js
@@ -10,13 +10,6 @@ load("jstests/aggregation/sources/densify/libs/densify_in_js.js");
(function() {
"use strict";
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
const collName = jsTestName();
const coll = db.getCollection(collName);
coll.drop();
@@ -25,7 +18,7 @@ coll.drop();
for (let i = 0; i < densifyUnits.length; i++) {
const unit = densifyUnits[i];
coll.drop();
- const base = unit ? new Date(2021, 0, 1) : 0;
+ const base = unit ? new ISODate("2021-01-01") : 0;
const {add} = getArithmeticFunctionsForUnit(unit);
const runDensifyRangeTest = ({step, bounds}, msg) => testDensifyStage({
diff --git a/jstests/aggregation/sources/densify/full_range.js b/jstests/aggregation/sources/densify/full_range.js
index 0fc8d247288..66f13540019 100644
--- a/jstests/aggregation/sources/densify/full_range.js
+++ b/jstests/aggregation/sources/densify/full_range.js
@@ -10,13 +10,6 @@ load("jstests/aggregation/sources/densify/libs/densify_in_js.js");
(function() {
"use strict";
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
const collName = jsTestName();
const coll = db.getCollection(collName);
coll.drop();
@@ -25,7 +18,7 @@ coll.drop();
for (let i = 0; i < densifyUnits.length; i++) {
const unit = densifyUnits[i];
coll.drop();
- const base = unit ? new Date(2021, 0, 1) : 0;
+ const base = unit ? new ISODate("2021-01-01") : 0;
const {add} = getArithmeticFunctionsForUnit(unit);
// Run all tests for different step values.
diff --git a/jstests/aggregation/sources/densify/generated_limit.js b/jstests/aggregation/sources/densify/generated_limit.js
index 704de96dac2..45acd24e404 100644
--- a/jstests/aggregation/sources/densify/generated_limit.js
+++ b/jstests/aggregation/sources/densify/generated_limit.js
@@ -12,13 +12,6 @@
load("jstests/noPassthrough/libs/server_parameter_helpers.js"); // For setParameterOnAllHosts.
load("jstests/libs/discover_topology.js"); // For findNonConfigNodes.
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
const paramName = "internalQueryMaxAllowedDensifyDocs";
const origParamValue = assert.commandWorked(
db.adminCommand({getParameter: 1, internalQueryMaxAllowedDensifyDocs: 1}))[paramName];
diff --git a/jstests/aggregation/sources/densify/libs/densify_in_js.js b/jstests/aggregation/sources/densify/libs/densify_in_js.js
index 48b63298499..4c92bd572bc 100644
--- a/jstests/aggregation/sources/densify/libs/densify_in_js.js
+++ b/jstests/aggregation/sources/densify/libs/densify_in_js.js
@@ -13,18 +13,18 @@ load("jstests/aggregation/extras/utils.js"); // arrayEq
*/
const makeArithmeticHelpers = (unitName, factor) => {
const getter = date => {
- const newDate = new Date(date);
+ const newDate = new ISODate(date.toISOString());
// Calling the proper function on the passed in date object. If the unitName was "Seconds"
// would be equivalent to `newDate.getSeconds()`.
- return newDate["get" + unitName]();
+ return newDate["getUTC" + unitName]();
};
// Return a new date with the proper unit adjusted with the second parameter.
// Dates and the setter helpers are generally mutable, but this function will make sure
// the arithmetic helpers won't mutate their inputs.
const setter = (date, newComponent) => {
- const newDate = new Date(date);
- newDate["set" + unitName](newComponent);
+ const newDate = new ISODate(date.toISOString());
+ newDate["setUTC" + unitName](newComponent);
return newDate;
};
diff --git a/jstests/aggregation/sources/densify/libs/parse_util.js b/jstests/aggregation/sources/densify/libs/parse_util.js
index 355e3aef436..7ccedefd81d 100644
--- a/jstests/aggregation/sources/densify/libs/parse_util.js
+++ b/jstests/aggregation/sources/densify/libs/parse_util.js
@@ -9,14 +9,6 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
}
function runTest(stageName) {
- const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
- if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
- }
-
// Required fields.
const kIDLRequiredFieldErrorCode = 40414;
assert.commandFailedWithCode(
@@ -53,7 +45,7 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
field: "a",
range: {
step: 1.0,
- bounds: [new Date("2020-01-01"), new Date("2020-01-02")],
+ bounds: [new ISODate("2020-01-01"), new ISODate("2020-01-02")],
unit: 1000
}
}
@@ -67,7 +59,7 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
run({
[stageName]: {
field: "a",
- range: {step: 1.0, bounds: [new Date("2020-01-01")], unit: "second"}
+ range: {step: 1.0, bounds: [new ISODate("2020-01-01")], unit: "second"}
}
}),
5733403,
@@ -118,7 +110,7 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
field: "a",
range: {
step: 1.0,
- bounds: [new Date("2020-01-01"), new Date("2019-01-01")],
+ bounds: [new ISODate("2020-01-01"), new ISODate("2019-01-01")],
unit: "second"
}
}
@@ -133,7 +125,8 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
// Mixed numeric and date bounds
assert.commandFailedWithCode(
run({
- [stageName]: {field: "a", range: {step: 1.0, bounds: [1, new Date("2020-01-01")]}}
+ [stageName]:
+ {field: "a", range: {step: 1.0, bounds: [1, new ISODate("2020-01-01")]}}
}),
5733406,
"a bounding array must contain either both dates or both numeric types");
@@ -141,7 +134,7 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
run({
[stageName]: {
field: "a",
- range: {step: 1.0, bounds: [new Date("2020-01-01"), 1], unit: "second"}
+ range: {step: 1.0, bounds: [new ISODate("2020-01-01"), 1], unit: "second"}
}
}),
5733402,
@@ -154,7 +147,7 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
field: "a",
range: {
step: 1.0,
- bounds: [new Date("2020-01-01"), new Date("2021-01-01")],
+ bounds: [new ISODate("2020-01-01"), new ISODate("2021-01-01")],
unit: "day"
}
}
@@ -165,7 +158,7 @@ let parseUtil = (function(db, coll, stageName, options = {}) {
partitionByFields: ["b", "c"],
range: {
step: 1.0,
- bounds: [new Date("2020-01-01"), new Date("2021-01-01")],
+ bounds: [new ISODate("2020-01-01"), new ISODate("2021-01-01")],
unit: "week"
}
}
diff --git a/jstests/aggregation/sources/densify/memory_limit.js b/jstests/aggregation/sources/densify/memory_limit.js
index 91f793d5985..06f5026f032 100644
--- a/jstests/aggregation/sources/densify/memory_limit.js
+++ b/jstests/aggregation/sources/densify/memory_limit.js
@@ -13,13 +13,6 @@ load("jstests/aggregation/extras/utils.js"); // For arrayEq.
load("jstests/noPassthrough/libs/server_parameter_helpers.js"); // For setParameterOnAllHosts.
load("jstests/libs/discover_topology.js"); // For findNonConfigNodes.
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
const origParamValue = assert.commandWorked(db.adminCommand({
getParameter: 1,
internalDocumentSourceDensifyMaxMemoryBytes: 1
diff --git a/jstests/aggregation/sources/densify/partitions.js b/jstests/aggregation/sources/densify/partitions.js
index 4517e753c5a..fc0339d3a17 100644
--- a/jstests/aggregation/sources/densify/partitions.js
+++ b/jstests/aggregation/sources/densify/partitions.js
@@ -11,14 +11,6 @@
load("jstests/aggregation/extras/utils.js"); // arrayEq
-const featureEnabled =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureFlagDensify: 1}))
- .featureFlagDensify.value;
-if (!featureEnabled) {
- jsTestLog("Skipping test because the densify feature flag is disabled");
- return;
-}
-
const coll = db[jsTestName()];
function buildErrorString(found, expected) {
@@ -57,10 +49,10 @@ function testOneDates() {
coll.drop();
const testDocs = [
- {val: new Date(2021, 0, 1), partition: 0},
- {val: new Date(2021, 0, 3), partition: 0},
- {val: new Date(2021, 0, 1), partition: 1},
- {val: new Date(2021, 0, 3), partition: 1}
+ {val: new ISODate("2021-01-01"), partition: 0},
+ {val: new ISODate("2021-01-03"), partition: 0},
+ {val: new ISODate("2021-01-01"), partition: 1},
+ {val: new ISODate("2021-01-03"), partition: 1}
];
assert.commandWorked(coll.insert(testDocs));
@@ -75,8 +67,10 @@ function testOneDates() {
}
]);
const resultArray = result.toArray();
- const testExpected = testDocs.concat(
- [{val: new Date(2021, 0, 2), partition: 0}, {val: new Date(2021, 0, 2), partition: 1}]);
+ const testExpected = testDocs.concat([
+ {val: new ISODate("2021-01-02"), partition: 0},
+ {val: new ISODate("2021-01-02"), partition: 1}
+ ]);
assert(arrayEq(resultArray, testExpected), buildErrorString(resultArray, testExpected));
coll.drop();
}
@@ -297,13 +291,16 @@ function fullTestTwoDates(stepVal = 2) {
let testDocs = [];
let testExpected = [];
// Add an initial document.
- testDocs.push({val: new Date(2021, 0, 1), part: 0});
- testDocs.push({val: new Date(2021, 0, 1), part: 1});
- testDocs.push({val: new Date(2031, 0, 1), part: 2});
- testDocs.push({val: new Date(2025, 0, 1), part: 3});
+ testDocs.push({val: new ISODate("2021-01-01"), part: 0});
+ testDocs.push({val: new ISODate("2021-01-01"), part: 1});
+ testDocs.push({val: new ISODate("2031-01-01"), part: 2});
+ testDocs.push({val: new ISODate("2025-01-01"), part: 3});
for (let densifyVal = 0; densifyVal < 11; densifyVal += stepVal) {
for (let partitionVal = 0; partitionVal <= 3; partitionVal++) {
- testExpected.push({val: new Date(2021 + densifyVal, 0, 1), part: partitionVal});
+ testExpected.push({
+ val: new ISODate((2021 + densifyVal).toString().padStart(2, '0') + "-01-01"),
+ part: partitionVal
+ });
}
}
assert.commandWorked(coll.insert(testDocs));
@@ -442,15 +439,18 @@ function rangeTestTwoDates() {
coll.drop();
let testDocs = [];
let testExpected = [];
- testDocs.push({val: new Date(2021, 0, 1), part: 0});
- testExpected.push({val: new Date(2021, 0, 1), part: 0});
- testDocs.push({val: new Date(2021, 5, 1), part: 1});
- testExpected.push({val: new Date(2021, 5, 1), part: 1});
- testDocs.push({val: new Date(2021, 10, 1), part: 2});
- testExpected.push({val: new Date(2021, 10, 1), part: 2});
+ testDocs.push({val: new ISODate("2021-01-01"), part: 0});
+ testExpected.push({val: new ISODate("2021-01-01"), part: 0});
+ testDocs.push({val: new ISODate("2021-06-01"), part: 1});
+ testExpected.push({val: new ISODate("2021-06-01"), part: 1});
+ testDocs.push({val: new ISODate("2021-11-01"), part: 2});
+ testExpected.push({val: new ISODate("2021-11-01"), part: 2});
for (let densifyVal = 4; densifyVal < 8; densifyVal += 2) {
for (let partitionVal = 0; partitionVal <= 2; partitionVal++) {
- testExpected.push({val: new Date(2021, densifyVal, 1), part: partitionVal});
+ testExpected.push({
+ val: new ISODate("2021-" + densifyVal.toString().padStart(2, '0') + "-01"),
+ part: partitionVal
+ });
}
}
assert.commandWorked(coll.insert(testDocs));
@@ -459,8 +459,11 @@ function rangeTestTwoDates() {
{
$densify: {
field: "val",
- range:
- {step: 2, unit: "month", bounds: [new Date(2021, 4, 1), new Date(2021, 8, 1)]},
+ range: {
+ step: 2,
+ unit: "month",
+ bounds: [new ISODate("2021-05-01"), new ISODate("2021-09-01")]
+ },
partitionByFields: ["part"]
}
},
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp
index 5ecb195903e..393fccc9611 100644
--- a/src/mongo/db/pipeline/document_source_densify.cpp
+++ b/src/mongo/db/pipeline/document_source_densify.cpp
@@ -118,23 +118,19 @@ RangeStatement RangeStatement::parse(RangeSpec spec) {
return range;
}
-REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
- densify,
- LiteParsedDocumentSourceDefault::parse,
- document_source_densify::createFromBson,
- AllowedWithApiStrict::kNeverInVersion1,
- AllowedWithClientType::kAny,
- multiversion::FeatureCompatibilityVersion::kVersion_5_1,
- ::mongo::feature_flags::gFeatureFlagDensify.isEnabledAndIgnoreFCV());
-
-REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
- _internalDensify,
- LiteParsedDocumentSourceDefault::parse,
- DocumentSourceInternalDensify::createFromBson,
- AllowedWithApiStrict::kInternal,
- AllowedWithClientType::kInternal,
- multiversion::FeatureCompatibilityVersion::kVersion_5_1,
- ::mongo::feature_flags::gFeatureFlagDensify.isEnabledAndIgnoreFCV());
+REGISTER_DOCUMENT_SOURCE_WITH_MIN_VERSION(densify,
+ LiteParsedDocumentSourceDefault::parse,
+ document_source_densify::createFromBson,
+ AllowedWithApiStrict::kNeverInVersion1,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1)
+
+REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(_internalDensify,
+ LiteParsedDocumentSourceDefault::parse,
+ DocumentSourceInternalDensify::createFromBson,
+ AllowedWithApiStrict::kInternal,
+ AllowedWithClientType::kInternal,
+ multiversion::FeatureCompatibilityVersion::kVersion_5_1,
+ true);
namespace document_source_densify {
diff --git a/src/mongo/db/pipeline/document_source_densify_test.cpp b/src/mongo/db/pipeline/document_source_densify_test.cpp
index 489dd1564d7..79b16303eb9 100644
--- a/src/mongo/db/pipeline/document_source_densify_test.cpp
+++ b/src/mongo/db/pipeline/document_source_densify_test.cpp
@@ -50,23 +50,6 @@ using DensifyPartitionNumericTest = AggregationContextFixture;
using DensifyCloneTest = AggregationContextFixture;
using DensifyStepTest = AggregationContextFixture;
-MONGO_INITIALIZER_GENERAL(turnOnDensifyFlag,
- ("AllFailPointsRegistered", "EndServerParameterRegistration"),
- ("BeginDocumentSourceRegistration",
- "addToDocSourceParserMap__internalDensify"))
-(InitializerContext*) {
- const auto& spMap = ServerParameterSet::getGlobal()->getMap();
- const auto& spIt = spMap.find("featureFlagDensify");
- invariant(spIt != spMap.end(), str::stream() << "spMap keys: " << spMap.size());
-
- auto* sp = spIt->second;
- invariant(sp);
- BSONObjBuilder bob;
- sp->appendSupportingRoundtrip(nullptr, bob, "featureFlagDensify");
- // Set to the new value
- uassertStatusOK(sp->set(BSON("featureFlagDensify" << true).firstElement()));
-}
-
Date_t makeDate(std::string dateStr) {
auto statusDate = dateFromISOString(dateStr);
ASSERT_TRUE(statusDate.isOK());
diff --git a/src/mongo/db/query/query_feature_flags.idl b/src/mongo/db/query/query_feature_flags.idl
index 23826dddbf5..f74d17705ca 100644
--- a/src/mongo/db/query/query_feature_flags.idl
+++ b/src/mongo/db/query/query_feature_flags.idl
@@ -42,11 +42,6 @@ feature_flags:
default: true
version: 5.1
- featureFlagDensify:
- description: "Feature flag for allowing a $densify stage in an aggregation pipeline"
- cpp_varname: gFeatureFlagDensify
- default: false
-
featureFlagShardedTimeSeries:
description: "Feature flag for allowing sharding a Time Series collection"
cpp_varname: gFeatureFlagShardedTimeSeries