Since drivers depend on the error code to throw exception for maxTimeMS timeout, interrupted commands on mongos should propagate the error code.
The following commands have this issue.
+ aggregate. Wrong error code 17022, 50 is expected (known bug for javascript interruption error code).
The others lack top-level error code.
+ count
+ mapreduce
+ text
+ moveChunk
+ collStats
Commands output:
----
Testing aggregate
----
{
"code" : 17022,
"ok" : 0,
"errmsg" : "exception: sharded pipeline failed on shard shard0001: { ok: 0.0, errmsg: \"operation exceeded time limit\", code: 50 }"
}
----
Testing count
----
{
"shards" : {
},
"cause" : {
"ok" : 0,
"errmsg" : "operation exceeded time limit",
"code" : 50
},
"ok" : 0,
"errmsg" : "failed on : shard0000"
}
----
Testing mapreduce
----
{
"ok" : 0,
"errmsg" : "MR parallel processing failed: { ok: 0.0, errmsg: \"operation exceeded time limit\", code: 50 }"
}
----
Testing text
----
{
"rawresult" : {
"ok" : 0,
"errmsg" : "operation exceeded time limit",
"code" : 50
},
"ok" : 0,
"errmsg" : "failure on shard: shard0000:localhost:30000: errmsg: \"operation exceeded time limit\""
}
----
Testing moveChunk
----
{
"cause" : {
"ok" : 0,
"errmsg" : "operation exceeded time limit",
"code" : 50
},
"ok" : 0,
"errmsg" : "move failed"
}
----
Testing collStats
----
{
"sharded" : true,
"ok" : 0,
"errmsg" : "failed on shard: { ok: 0.0, errmsg: \"operation exceeded time limit\", code: 50 }"
}
For example, to reproduce this issue, running map-reduce against sharded collection with a small maxTimeMS gives the following error.
mongos> var mapReduceArg = { ... mapreduce: "foo", ... map: function() { emit(this.i, 1); }, ... reduce: function(key, value) { return value.length }, ... out: { replace: "mapReduceOut" }, ... maxTimeMS: 10, ... }; mongos> db.runCommand(mapReduceArg) { "ok" : 0, "errmsg" : "MR parallel processing failed: { errmsg: \"exception: JavaScript execution terminated\", code: 13475, ok: 0.0 }" }