summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2020-04-16 14:04:31 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-16 19:44:34 +0000
commitd05acff26c4c5a7fb27e9d0c7e31e4a3167fa7fe (patch)
tree35b6459635457caf5731264f3c7cac114a03f59e /jstests/sharding
parentde18c56b913e055708310ac88cc31bef238ad66c (diff)
downloadmongo-d05acff26c4c5a7fb27e9d0c7e31e4a3167fa7fe.tar.gz
SERVER-47117 clear maxTimeMSForHedgedReads delay from the getMore on hedge reads
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/hedged_reads.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/sharding/hedged_reads.js b/jstests/sharding/hedged_reads.js
index f1d2e1a97ab..105fed6cb8c 100644
--- a/jstests/sharding/hedged_reads.js
+++ b/jstests/sharding/hedged_reads.js
@@ -74,10 +74,18 @@ const testDB = st.s.getDB(dbName);
const kBlockCmdTimeMS = 5 * 60 * 1000;
const kWaitKillOpTimeoutMS = 5 * 1000;
+const numDocs = 10;
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
st.ensurePrimaryShard(dbName, st.shard0.shardName);
+let bulk = testDB[collName].initializeUnorderedBulkOp();
+for (let i = 0; i < numDocs; i++) {
+ bulk.insert({x: i});
+}
+assert.commandWorked(bulk.execute());
+assert.commandWorked(st.s.adminCommand({flushRouterConfig: 1}));
+
jsTest.log(
"Verify that maxTimeMS expiration of the additional request does not affect the command result");
// The hedged read will have the maxTimeMS set to 10ms, hence need to sleep longer than that.
@@ -113,6 +121,7 @@ try {
kWaitKillOpTimeoutMS);
} finally {
clearCommandDelay(sortedNodes[0]);
+ clearCommandDelay(sortedNodes[1]);
}
jsTest.log(
@@ -142,8 +151,38 @@ try {
"Timed out waiting for the operation run by the additional request to be killed",
kWaitKillOpTimeoutMS);
} finally {
+ clearCommandDelay(sortedNodes[0]);
clearCommandDelay(sortedNodes[1]);
}
+jsTest.log("Verify that the getMore on hedge request do not inherit maxTimeMS");
+try {
+ assert.commandWorked(st.s.adminCommand({setParameter: 1, maxTimeMSForHedgedReads: 100}));
+
+ // force to open hedge read cursor on sortedNodes[1]
+ setCommandDelay(sortedNodes[0], "find", 100, ns);
+
+ // $where with sleep is used because blocking command via failCommand does not affect the opCtx
+ // deadlines as it blocks and unblocks the command before it starts execution.
+ const comment = "test_getmore_on_additional_request_" + ObjectId();
+ let findRes = assert.commandWorked(testDB.runCommand({
+ find: collName,
+ filter: {$where: "sleep(200); return true;", x: {$gte: 0}},
+ $readPreference: {mode: "nearest"},
+ batchSize: 0,
+ comment: comment
+ }));
+
+ const cursorId = findRes.cursor.id;
+ assert.neq(0, cursorId);
+
+ // confirm that getMore does not time out.
+ let getMoreRes =
+ assert.commandWorked(testDB.runCommand({getMore: cursorId, collection: collName}));
+ assert.eq(getMoreRes.cursor.nextBatch.length, numDocs);
+} finally {
+ clearCommandDelay(sortedNodes[0]);
+}
+
st.stop();
}());