summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough
diff options
context:
space:
mode:
authorEric Cox <eric.cox@mongodb.com>2022-02-16 17:27:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-16 18:46:23 +0000
commit69f2f33c4c9edcceb013e16e6b6d737a20b481b3 (patch)
tree17aa9b88a25898d79f3b2e48570d3c0504f4c922 /jstests/noPassthrough
parent65348d1c32d7b46eea6e8120e56337c4475afc49 (diff)
downloadmongo-69f2f33c4c9edcceb013e16e6b6d737a20b481b3.tar.gz
SERVER-63328 Relax checks for write lock to support spilling to temp WT record store on secondaries
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r--jstests/noPassthrough/spill_to_disk_secondary_read.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/jstests/noPassthrough/spill_to_disk_secondary_read.js b/jstests/noPassthrough/spill_to_disk_secondary_read.js
new file mode 100644
index 00000000000..68db95fda66
--- /dev/null
+++ b/jstests/noPassthrough/spill_to_disk_secondary_read.js
@@ -0,0 +1,82 @@
+/*
+ * Test that $group and $setWindowFields spill to the WT RecordStore on secondaries with
+ * writeConcern greater than w:1.
+ * @tags: [requires_replication]
+ */
+(function() {
+"use strict";
+
+const replTest = new ReplSetTest({
+ nodes: 3,
+});
+
+replTest.startSet();
+replTest.initiate();
+
+// Test that spilling '$group' pipeline on a secondary works with a writeConcern greater than w:1.
+let primary = replTest.getPrimary();
+const insertColl = primary.getDB("test").foo;
+for (let i = 0; i < 500; ++i) {
+ assert.commandWorked(insertColl.insert({a: i, string: "test test test"}));
+}
+
+let secondary = replTest.getSecondary();
+assert.commandWorked(secondary.adminCommand(
+ {setParameter: 1, internalQuerySlotBasedExecutionHashAggApproxMemoryUseInBytesBeforeSpill: 1}));
+
+const readColl = secondary.getDB("test").foo;
+
+let pipeline = [{$group: {_id: '$a', s: {$addToSet: '$string'}, p: {$push: '$a'}}}];
+
+let res =
+ readColl
+ .aggregate(
+ pipeline,
+ {allowDiskUse: true, readConcern: {level: "majority"}, writeConcern: {"w": "majority"}})
+ .toArray();
+
+insertColl.drop();
+
+// Test that spilling '$setWindowFields' pipeline on a secondary works with a writeConcern greater
+// than w:1.
+let avgDocSize = 274;
+let smallPartitionSize = 6;
+let largePartitionSize = 21;
+const insertCollWFs = primary.getDB("test").bar;
+
+// Create small partition.
+for (let i = 0; i < smallPartitionSize; i++) {
+ assert.commandWorked(insertCollWFs.insert({_id: i, val: i, partition: 1}));
+}
+// Create large partition.
+for (let i = 0; i < largePartitionSize; i++) {
+ assert.commandWorked(insertCollWFs.insert({_id: i + smallPartitionSize, val: i, partition: 2}));
+}
+
+assert.commandWorked(secondary.adminCommand({
+ setParameter: 1,
+ internalDocumentSourceSetWindowFieldsMaxMemoryBytes: largePartitionSize * avgDocSize + 1
+}));
+
+const readCollWFs = secondary.getDB("test").bar;
+
+pipeline = [
+ {
+ $setWindowFields: {
+ partitionBy: "$partition",
+ sortBy: {partition: 1},
+ output: {arr: {$push: "$val", window: {documents: [-25, 25]}}}
+ }
+ },
+ {$sort: {_id: 1}}
+];
+
+res =
+ readCollWFs
+ .aggregate(
+ pipeline,
+ {allowDiskUse: true, readConcern: {level: "majority"}, writeConcern: {"w": "majority"}})
+ .toArray();
+
+replTest.stopSet();
+})();