|
Drivers that implement DRIVERS-103 and/or DRIVERS-132 according to spec determine whether a command exists like so:
try
|
result = db.runCommand({<command>: ...})
|
catch error
|
if error code == 59 or error code == Null
|
<fallback to existing code for backward compatibility>
|
else
|
re-raise error
|
However, older mongos versions use code 13390 when a command is not found, so drivers throw an error instead of falling back to the legacy code path.
This is a problem for all versions of mongos previous to 2.4.0:
> db.version()
|
1.8.0
|
> db.runCommand("foobar")
|
Thu May 1 13:07:55 uncaught exception: error { "$err" : "unrecognized command: foobar", "code" : 13390 }
|
> db.version()
|
1.8.5
|
> db.runCommand("foobar")
|
Thu May 1 13:10:00 uncaught exception: error { "$err" : "unrecognized command: foobar", "code" : 13390 }
|
> db.version()
|
2.0.0
|
> db.runCommand("foobar")
|
Thu May 1 13:11:29 uncaught exception: error { "$err" : "unrecognized command: foobar", "code" : 13390 }
|
> db.version()
|
2.0.9
|
> db.runCommand("foobar")
|
Thu May 1 13:13:07 uncaught exception: error { "$err" : "unrecognized command: foobar", "code" : 13390 }
|
> db.version()
|
2.2.0
|
> db.runCommand("foobar")
|
Thu May 1 13:13:58 uncaught exception: error { "$err" : "unrecognized command: foobar", "code" : 13390 }
|
> db.version()
|
2.2.7
|
> db.runCommand("foobar")
|
Thu May 1 13:14:51 uncaught exception: error { "$err" : "unrecognized command: foobar", "code" : 13390 }
|
> db.version()
|
2.4.0
|
> db.runCommand("foobar")
|
{ "ok" : 0, "errmsg" : "no such cmd: foobar" }
|
> db.version()
|
2.4.10
|
> db.runCommand("foobar")
|
{ "ok" : 0, "errmsg" : "no such cmd: foobar" }
|
Note: This is not a problem for any version of mongod
> db.version()
|
1.8.0
|
> db.runCommand("foobar")
|
{
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
},
|
"ok" : 0
|
}
|
> db.version()
|
1.8.5
|
> db.runCommand("foobar")
|
{
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
},
|
"ok" : 0
|
}
|
> db.version()
|
2.0.0
|
> db.runCommand("foobar")
|
{
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
},
|
"ok" : 0
|
}
|
> db.version()
|
2.0.9
|
> db.runCommand("foobar")
|
{
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
},
|
"ok" : 0
|
}
|
> db.version()
|
2.2.0
|
> db.runCommand("foobar")
|
{
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
},
|
"ok" : 0
|
}
|
> db.version()
|
2.2.7
|
>
|
> db.runCommand("foobar")
|
{
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
},
|
"ok" : 0
|
}
|
> db.version()
|
2.4.0
|
> db.runCommand("foobar")
|
{
|
"ok" : 0,
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
}
|
}
|
> db.version()
|
2.4.10
|
> db.runCommand("foobar")
|
{
|
"ok" : 0,
|
"errmsg" : "no such cmd: foobar",
|
"bad cmd" : {
|
"foobar" : 1
|
}
|
}
|
|