[英]Why I am getting network error on the primary shard?
我有两个集合,即'scanner'和'applicationinfo'。 两者都没有伤害。 当我在主分片上运行以下查询时:
db.scans.aggregate(
[
{
$match:{
"customerId":500,
"startTime":{
$gte:1568073600000
},
"endTime":{
$lte:1568160000000
}
}
},
{
$lookup:{
"from":"applicationinfo",
"let":{
"sha":"$sha"
},
"pipeline":[
{
$match:{
"customerId":500,
$expr:{
$eq:["$sha256","$$sha"]
}
}
},
{
$sort:{
"_id":-1
}
},
{
$limit:1
},
{
$project:{
"_id":0
}
}
],
"as":"applicationinfoLookup"
}
}
],
{
"allowDiskUse":true
}
).pretty()
它抛出错误:
2019-09-11T11:23:30.379+0000 E QUERY [js] Error: error doing query: failed: network error while attempting to run command 'aggregate' on host '127.0.0.1:27001' :
DB.prototype.runCommand@src/mongo/shell/db.js:168:1
DB.prototype.runReadCommand@src/mongo/shell/db.js:139:16
DB.prototype._runAggregate/doAgg<@src/mongo/shell/db.js:239:60
DB.prototype._runAggregate@src/mongo/shell/db.js:242:21
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1056:12
当对mongos触发相同的查询时,将引发以下错误:
2019-09-11T11:51:53.743+0530 E QUERY [js] Error: command failed: {
"ok" : 0,
"errmsg" : "Could not find host matching read preference { mode: \"primary\" } for set 1",
"code" : 133,
"codeName" : "FailedToSatisfyReadPreference",
"operationTime" : Timestamp(1568182910, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1568182910, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
} : aggregate failed :
_geterrorwithcode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertcommandworked@src/mongo/shell/assert.js:534:17
assert.commandworked@src/mongo/shell/assert.js:618:16
db.prototype._runaggregate@src/mongo/shell/db.js:260:9
dbcollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12
@(shell):1:1
奇怪的是,当我从查找管道中删除最后一个投影阶段时,查询运行顺利。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.