summaryrefslogtreecommitdiff
path: root/jstests/aggregation/sources/setWindowFields
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/aggregation/sources/setWindowFields')
-rw-r--r--jstests/aggregation/sources/setWindowFields/derivative.js6
-rw-r--r--jstests/aggregation/sources/setWindowFields/explain.js7
-rw-r--r--jstests/aggregation/sources/setWindowFields/integral.js6
-rw-r--r--jstests/aggregation/sources/setWindowFields/memory_limit.js6
-rw-r--r--jstests/aggregation/sources/setWindowFields/output_overwrites_existing_data.js2
-rw-r--r--jstests/aggregation/sources/setWindowFields/range_wrong_type.js36
-rw-r--r--jstests/aggregation/sources/setWindowFields/spill_to_disk.js4
7 files changed, 51 insertions, 16 deletions
diff --git a/jstests/aggregation/sources/setWindowFields/derivative.js b/jstests/aggregation/sources/setWindowFields/derivative.js
index b457a1fa097..a57af814b30 100644
--- a/jstests/aggregation/sources/setWindowFields/derivative.js
+++ b/jstests/aggregation/sources/setWindowFields/derivative.js
@@ -192,9 +192,9 @@ function explainUnit(unit) {
return coll.runCommand(
{explain: {aggregate: coll.getName(), cursor: {}, pipeline: [derivativeStage(unit)]}});
}
-assert.commandFailedWithCode(explainUnit('year'), 5490704);
-assert.commandFailedWithCode(explainUnit('quarter'), 5490704);
-assert.commandFailedWithCode(explainUnit('month'), 5490704);
+assert.commandFailedWithCode(explainUnit('year'), 5490710);
+assert.commandFailedWithCode(explainUnit('quarter'), 5490710);
+assert.commandFailedWithCode(explainUnit('month'), 5490710);
assert.commandWorked(explainUnit('week'));
assert.commandWorked(explainUnit('day'));
assert.commandWorked(explainUnit('hour'));
diff --git a/jstests/aggregation/sources/setWindowFields/explain.js b/jstests/aggregation/sources/setWindowFields/explain.js
index a070aae7b0e..cae112cb9e5 100644
--- a/jstests/aggregation/sources/setWindowFields/explain.js
+++ b/jstests/aggregation/sources/setWindowFields/explain.js
@@ -16,9 +16,8 @@ coll.drop();
const bigStr = Array(1025).toString(); // 1KB of ','
const nDocs = 1000;
const nPartitions = 50;
-// Initial docSize is 1292, after fields are loaded into Document's cache they are 2332.
-// Not const because post-cache doc size changes based on the number of fields accessed.
-let docSize = 2332;
+// Size was found through logging in 'SpillableCache' class.
+const docSize = 1292;
let bulk = coll.initializeUnorderedBulkOp();
for (let i = 1; i <= nDocs; i++) {
@@ -138,8 +137,6 @@ function checkExplainResult(pipeline, expectedFunctionMemUsages, expectedTotalMe
// The partition iterator will only hold five documents at once. After they are added to the
// removable document executor they will be released.
const numDocsHeld = 5;
- // This test accesses fewer fields, reduce docSize accordingly.
- docSize = 1292;
let pipeline = [
{
$setWindowFields: {
diff --git a/jstests/aggregation/sources/setWindowFields/integral.js b/jstests/aggregation/sources/setWindowFields/integral.js
index a62033e2b4f..bb0e962c504 100644
--- a/jstests/aggregation/sources/setWindowFields/integral.js
+++ b/jstests/aggregation/sources/setWindowFields/integral.js
@@ -115,9 +115,9 @@ function explainUnit(unit) {
}
});
}
-assert.commandFailedWithCode(explainUnit('year'), 5490704);
-assert.commandFailedWithCode(explainUnit('quarter'), 5490704);
-assert.commandFailedWithCode(explainUnit('month'), 5490704);
+assert.commandFailedWithCode(explainUnit('year'), 5490710);
+assert.commandFailedWithCode(explainUnit('quarter'), 5490710);
+assert.commandFailedWithCode(explainUnit('month'), 5490710);
assert.commandWorked(explainUnit('week'));
assert.commandWorked(explainUnit('day'));
assert.commandWorked(explainUnit('hour'));
diff --git a/jstests/aggregation/sources/setWindowFields/memory_limit.js b/jstests/aggregation/sources/setWindowFields/memory_limit.js
index e64781d3eca..a88717d0331 100644
--- a/jstests/aggregation/sources/setWindowFields/memory_limit.js
+++ b/jstests/aggregation/sources/setWindowFields/memory_limit.js
@@ -61,6 +61,10 @@ assert.commandWorked(coll.runCommand({
allowDiskUse: false
}));
+setParameterOnAllHosts(nonConfigNodes,
+ "internalDocumentSourceSetWindowFieldsMaxMemoryBytes",
+ (perDocSize * docsPerPartition) + 1024);
+
// Test that the query fails with a window function that stores documents.
assert.commandFailedWithCode(coll.runCommand({
aggregate: coll.getName(),
@@ -74,7 +78,7 @@ assert.commandFailedWithCode(coll.runCommand({
cursor: {},
allowDiskUse: false
}),
- 5414201);
+ [5643011, 5414201]);
// Reset limit for other tests.
setParameterOnAllHosts(
nonConfigNodes, "internalDocumentSourceSetWindowFieldsMaxMemoryBytes", 100 * 1024 * 1024);
diff --git a/jstests/aggregation/sources/setWindowFields/output_overwrites_existing_data.js b/jstests/aggregation/sources/setWindowFields/output_overwrites_existing_data.js
index 8301f78bbfc..3ec0290054f 100644
--- a/jstests/aggregation/sources/setWindowFields/output_overwrites_existing_data.js
+++ b/jstests/aggregation/sources/setWindowFields/output_overwrites_existing_data.js
@@ -9,8 +9,6 @@
(function() {
"use strict";
-// TODO SERVER-63811 Ensure the database exists so we get back non-empty results even in a sharded
-// cluster.
assert.commandWorked(db[jsTestName()].insert({dummy: 1}));
let windowResults = db.aggregate([
diff --git a/jstests/aggregation/sources/setWindowFields/range_wrong_type.js b/jstests/aggregation/sources/setWindowFields/range_wrong_type.js
new file mode 100644
index 00000000000..26001c40888
--- /dev/null
+++ b/jstests/aggregation/sources/setWindowFields/range_wrong_type.js
@@ -0,0 +1,36 @@
+/**
+ * Test that a window of the form [+N, unbounded] does not trigger a tassert
+ * on mixed-type input.
+ *
+ * Originally intended to reproduce SERVER-71387.
+ */
+(function() {
+"use strict";
+
+const coll = db.set_window_fields_range_wrong_type;
+coll.drop();
+assert.commandWorked(coll.insert([
+ // Numbers sort before strings, so we'll scan {a: 2} first.
+ {a: 2},
+ {a: 'xyz'},
+]));
+
+const err = assert.throws(() => {
+ return coll
+ .aggregate({
+ $setWindowFields: {
+ sortBy: {a: 1},
+ output: {
+ // The lower bound +3 excludes the current document {a: 2}.
+ // The only remaining document is {a: 'xyz'}.
+ // We wrongly consider {a: 'xyz'} to be 'within' the lower bound.
+ // Then, when we search for the upper bound, we are surprised
+ // to be starting from 'xyz' which is the wrong type.
+ b: {$max: 5, window: {range: [+3, 'unbounded']}},
+ },
+ }
+ })
+ .toArray();
+});
+assert.eq(err.code, 5429414, err);
+})();
diff --git a/jstests/aggregation/sources/setWindowFields/spill_to_disk.js b/jstests/aggregation/sources/setWindowFields/spill_to_disk.js
index 24d03721d03..b006c1e66d2 100644
--- a/jstests/aggregation/sources/setWindowFields/spill_to_disk.js
+++ b/jstests/aggregation/sources/setWindowFields/spill_to_disk.js
@@ -24,12 +24,12 @@ const coll = db[jsTestName()];
coll.drop();
// Doc size was found through logging the size in the SpillableCache. Partition sizes were chosen
// arbitrarily.
-let avgDocSize = 274;
+let avgDocSize = 171;
let smallPartitionSize = 6;
let largePartitionSize = 21;
setParameterOnAllHosts(DiscoverTopology.findNonConfigNodes(db.getMongo()),
"internalDocumentSourceSetWindowFieldsMaxMemoryBytes",
- avgDocSize * smallPartitionSize + 1);
+ avgDocSize * smallPartitionSize + 50);
seedWithTickerData(coll, 10);