Info
4.0.12
mongos
single shard - 1 node
mongos> db.getMongo().setReadPref('secondary')
mongos> db.test.find().explain()
2019-09-20T10:39:20.947-0500 E QUERY
[js] Error: explain failed: {
"ok" : 0,
"errmsg" : "Explain command on shard db1/localhost:27030 failed, caused by: { ok: 1.0 }",
"code" : 96,
"codeName" : "OperationFailed",
"operationTime" : Timestamp(1568993960, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1568993960, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
It doesn't fail with 'can't find the node matching read pref' because of a bug in ClusterExplain::downconvert
OperationContext* opCtx, const std::vector& responses) {
std::vector results;
for (auto& response : responses) {
Status status = Status::OK();
if (response.swResponse.isOK()) {
auto& result = response.swResponse.getValue().data;
status = getStatusFromCommandResult(result);
if (status.isOK()) {
invariant(response.shardHostAndPort);
results.emplace_back(
response.shardId, ConnectionString(*response.shardHostAndPort), result);
continue;
}
}
/////////////////// need to add this ------->
else status = response.swResponse.getStatus();
///////////////////
// Convert the error status back into the format of a command result.
BSONObjBuilder statusObjBob;
CommandHelpers::appendCommandStatusNoThrow(statusObjBob, status);
// Get the Shard object in order to get the ConnectionString.
auto shard =
uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getShard(opCtx, response.shardId));
results.emplace_back(response.shardId, shard->getConnString(), statusObjBob.obj());
}
return results;
}
Top User Comments
alex.komyagin@10gen.com commented on Fri, 20 Sep 2019 16:26:13 +0000:
Yeah!
daniel.hatcher commented on Fri, 20 Sep 2019 16:19:54 +0000:
alex.komyagin, this looks like a duplicate of SERVER-41099 and that fix just needs to be backported to the 4.0 release. Do you agree?