summaryrefslogtreecommitdiff
path: root/jstests/libs
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2017-08-11 14:17:17 -0400
committerEsha Maharishi <esha.maharishi@mongodb.com>2017-08-15 17:56:16 -0400
commitaa1c211dc382fa9fefc8709b9fbd9ae81befc88a (patch)
tree4d74c5f846dc5044b3b0b92cfb4c15b9fc509d85 /jstests/libs
parentac278086e705b289a784e4f40fe7b851b69a7b57 (diff)
downloadmongo-aa1c211dc382fa9fefc8709b9fbd9ae81befc88a.tar.gz
SERVER-30418 continuous stepdown override should catch the ManualInterventionRequired error code for mapReduce in addition to shardCollection
Diffstat (limited to 'jstests/libs')
-rw-r--r--jstests/libs/override_methods/sharding_continuous_config_stepdown.js52
1 files changed, 41 insertions, 11 deletions
diff --git a/jstests/libs/override_methods/sharding_continuous_config_stepdown.js b/jstests/libs/override_methods/sharding_continuous_config_stepdown.js
index a7cb2cf7447..dd5c9b5e7ef 100644
--- a/jstests/libs/override_methods/sharding_continuous_config_stepdown.js
+++ b/jstests/libs/override_methods/sharding_continuous_config_stepdown.js
@@ -268,9 +268,22 @@ tracking: {verbosity: 0} }";
* command.
*/
(function(original) {
+ let manualInterventionActions = {
+ removePartiallyWrittenChunks: function(mongosConn, ns, cmdObj, numAttempts) {
+ print("command " + tojson(cmdObj) + " failed after " + numAttempts +
+ " attempts due to seeing partially written chunks for collection " + ns +
+ ", probably due to a previous failed shardCollection attempt. Manually" +
+ " deleting chunks for " + ns +
+ " from config.chunks and retrying the command.");
+ assert.writeOK(mongosConn.getDB("config").chunks.remove(
+ {ns: ns}, {writeConcern: {w: "majority"}}));
+ }
+ };
+
Mongo.prototype.runCommand = function runCommand(dbName, cmdObj, options) {
const cmdName = Object.keys(cmdObj)[0];
- const commandsToRetry = new Set(["shardCollection", "shardcollection"]);
+ const commandsToRetry =
+ new Set(["mapReduce", "mapreduce", "shardCollection", "shardcollection"]);
if (!commandsToRetry.has(cmdName)) {
return original.apply(this, arguments);
@@ -291,16 +304,33 @@ tracking: {verbosity: 0} }";
if (cmdName === "shardCollection" || cmdName === "shardcollection") {
const ns = cmdObj[cmdName];
-
- print(
- "shardCollection command " + tojson(cmdObj) + " failed after " +
- numAttempts +
- " attempts due to partially written chunks. Manually deleting chunks for " +
- ns + " from config.chunks and retrying the shardCollection command.");
-
- // Remove the partially written chunks.
- assert.writeOK(this.getDB("config").chunks.remove(
- {ns: ns}, {writeConcern: {w: "majority"}}));
+ manualInterventionActions.removePartiallyWrittenChunks(
+ this, ns, cmdObj, numAttempts);
+ } else if (cmdName === "mapReduce" || cmdName === "mapreduce") {
+ const out = cmdObj.out;
+
+ // The output collection can be specified as a string argument to the mapReduce
+ // command's 'out' option, or nested under 'out.replace', 'out.merge', or
+ // 'out.reduce'.
+ let outCollName;
+ if (typeof out === "string") {
+ outCollName = out;
+ } else if (typeof out === "object") {
+ outCollName = out.replace || out.merge || out.reduce;
+ } else {
+ print("Could not parse the output collection's name from 'out' option in " +
+ tojson(cmdObj) +
+ "; not retrying on ManualInterventionRequired error " + tojson(res));
+ break;
+ }
+
+ // The output collection's database can optionally be specified under 'out.db',
+ // else it defaults to the input collection's database.
+ const outDbName = out.db || dbName;
+
+ const ns = outDbName + "." + outCollName;
+ manualInterventionActions.removePartiallyWrittenChunks(
+ this, ns, cmdObj, numAttempts);
}
}
return res;