“服务器x超时”在MongoDB聚合期间 [英] "Server x timed out" during MongoDB aggregation

查看:326
本文介绍了“服务器x超时”在MongoDB聚合期间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,定期在mongodb集合上运行聚合。随着数据的增长,聚合所需的时间也在增长。我的汇总脚本最近停止了工作,错误日志显示:

error:{[MongoError:server< x> timed out]
name:'MongoError',
message:'server< x>超时'$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $它在2米左右时间超时)。有没有人有其他调试提示? 2分钟的事情给我的印象是,我只需要在某处设置一些超时,但我无法弄清楚在哪里或者我只是陷入了一个红色的鲱鱼陷阱。



关于系统配置:此聚合脚本是在基于alpine的docker(v1.9.1)容器中运行的node.js(v5.9.1)应用程序。它使用 mongodb 节点驱动程序(v2.1.19)。运行mongod(v3.2.6)

解决方案

我的单个mongodb服务器(尽管这也在一个单独的环境中使用replSet)日志时间聚合也遇到同样的问题。我想我有解决方案。



我发现选项 socketTimeoutMS 是负责的。
检查您的mongo_client.js默认值 socketTimeoutMS 值。对我来说,它是 2分钟。 Mongodb模块版本2.1.18。



所以只需将这个选项添加到你的url中:

 code> mongodb:// localhost:27017 / test?maxPoolSize = 2& socketTimeoutMS = 60000 

它会将 timeout 设置为10分钟。这对我来说是个伎俩。


I have a script that periodically runs aggregation on a mongodb collection. As the dataset has grown, the amount of time it takes to aggregate has also grown. My aggregation script has recently stopped working consistently, and the error logs show: error: { [MongoError: server <x> timed out] name: 'MongoError', message: 'server <x> timed out' } I've tried debugging this, and the only pattern I can find is that this timeout seems to only occur when the aggregation takes longer than 2 minutes (it times out right around 2m). Does anyone have additional debugging tips for this? The 2-minute thing is giving me the impression that I just need to configure some timeout somewhere but I can't figure out where or if i'm just falling into a red-herring trap.

About the system configuration: This aggregation script is a node.js (v5.9.1) application running in an alpine-based docker (v1.9.1) container. It uses the mongodb node driver (v2.1.19). Single mongodb server (though this is also happening in a separate environment with a replSet) running mongod (v3.2.6)

解决方案

I got the same problem for logs time aggregation. I think I have the solution for you.

I found that the option socketTimeoutMS is responsible for that. Check your mongo_client.js default socketTimeoutMS value. For me it was 2min. Mongodb module version 2.1.18.

So just add this option into your url :

mongodb://localhost:27017/test?maxPoolSize=2&socketTimeoutMS=60000

It will set timeout to 10 mins. That does the trick for me.

这篇关于“服务器x超时”在MongoDB聚合期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆