每当我将.explain()附加到聚合中时,Mongo网络错误

时间:2019-07-22 19:35:25

标签: mongodb

背景

我正在运行具有mongos,集群服务器和2个分片的mongo集群。

我正在运行一个聚合命令,该命令在对大型集合进行分片后没有加快速度。我正在汇总上运行.explain(),以查看为什么没有看到任何性能提升。但是,每当我对它运行.explain()时,聚合都会失败。然后,我不能再mongo --port 27018一分钟了。然后又回来了。

问题

如何在非常大的馆藏(5000万条记录)上运行没有网络故障的aggregate.explain()?

更多信息

我的命令

db.items.explain().aggregate([
...     {$match: {"taglist":{$in:"white}},
...     {$unwind: "$taglist"},
...     {$match: {"taglist": {$in:Jids}}},
...     {$lookup: {"from": "tags", "localField": "taglist", "foreignField": "_id", as: "TagDetails" }},
...     {$unwind: "$TagDetails"},
...     {$group: { _id: "$TagDetails.tagvalue", cost: { $sum : "$cost"}}}
... ]);

我的错误:

2019-07-22T19:25:50.123+0000 E QUERY    [thread1] Error: error doing query: failed: network error while attempting to run command 'aggregate' on host '127.0.0.1:27018'  :
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:1212:12
constructor/this.aggregate@src/mongo/shell/explainable.js:110:24
@(shell):1:1
2019-07-22T19:25:50.125+0000 I NETWORK  [thread1] trying reconnect to 127.0.0.1:27018 (127.0.0.1) failed
2019-07-22T19:25:50.125+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27018, in(checking socket for error after poll), reason: Connection refused
2019-07-22T19:25:50.125+0000 I NETWORK  [thread1] reconnect 127.0.0.1:27018 (127.0.0.1) failed failed 
2019-07-22T19:25:50.127+0000 I NETWORK  [thread1] trying reconnect to 127.0.0.1:27018 (127.0.0.1) failed
2019-07-22T19:25:50.127+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27018, in(checking socket for error after poll), reason: Connection refused
2019-07-22T19:25:50.127+0000 I NETWORK  [thread1] reconnect 127.0.0.1:27018 (127.0.0.1) failed failed

我的mongo版本:

MongoDB shell version v3.6.9
MongoDB server version: 3.6.9

运行mongo --port 27018后我正在运行kubectl exec -it <<POD_NAME>> /bin/bash

编辑1

我的收藏有50,000,000条记录。我认为内存可能正在“装满”。因此,我收集了一个很小的10个文档。 .explain().aggregate可以很好地工作。因此,我更新了我的问题,涉及大集合。

0 个答案:

没有答案