diff options
author | Misha Tyulenev <misha@mongodb.com> | 2020-03-05 16:32:01 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-18 17:27:39 +0000 |
commit | 18128517432e6c4a7f9c9f5309e42366cab002e6 (patch) | |
tree | 5776c7c5030bdc31487cbe64142fe91b92a6e765 /jstests | |
parent | 2dea160044e73aa1f66878735f53695616715fbd (diff) | |
download | mongo-18128517432e6c4a7f9c9f5309e42366cab002e6.tar.gz |
SERVER-46607 ignore MaxTimeMSExpire error on hedged reads
(cherry picked from commit a924cde8580dd00409a0c8296e81ff73709ad1a2)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/hedged_reads.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/jstests/sharding/hedged_reads.js b/jstests/sharding/hedged_reads.js new file mode 100644 index 00000000000..76fd6e59a56 --- /dev/null +++ b/jstests/sharding/hedged_reads.js @@ -0,0 +1,55 @@ +/* + * Tests hedging metrics in the serverStatus output. + * @tags: [requires_fcv_44] + */ +(function() { +"use strict"; + +function setCommandDelay(nodeConn, command, delay) { + assert.commandWorked(nodeConn.adminCommand({ + configureFailPoint: "failCommand", + mode: "alwaysOn", + data: { + failInternalCommands: true, + blockConnection: true, + blockTimeMS: delay, + failCommands: [command], + } + })); +} + +function clearCommandDelay(nodeConn) { + assert.commandWorked(nodeConn.adminCommand({ + configureFailPoint: "failCommand", + mode: "off", + })); +} + +const st = new ShardingTest({shards: 2, rs: {nodes: 2}}); +const dbName = "foo"; +const collName = "bar"; +const ns = dbName + "." + collName; +const testDB = st.s.getDB(dbName); + +assert.commandWorked(st.s.adminCommand({enableSharding: dbName})); +st.ensurePrimaryShard(dbName, st.shard0.shardName); + +// Verify that MaxTimeMS expiration does not affect the command result. +try { + setCommandDelay(st.rs0.getPrimary(), "find", 500); + + // the hedged read will have the MaxTimeMS set to 10ms, hence need to sleep longer than that. + assert.commandWorked(testDB.runCommand({ + query: { + find: collName, + filter: {$where: "sleep(100); return true;"}, + $readPreference: {mode: "nearest"} + } + })); + +} finally { + clearCommandDelay(st.rs0.getPrimary()); +} + +st.stop(); +}()); |