dourao1896 2017-07-31 13:15
浏览 128

使用mgo的mongodb错误:net.OpError(net.timeoutError)

I keep getting errors when writing to mongo at unpredictable times and would like to find out the reason. I am using the mgo driver for Go. The error is of type net.OpError. Some of its relevant fields:

net.OpError{
  Err: net.timeoutError,
  Op: "read",
  Net: "tcp",
}

Currently I handle this error by reconnecting:

err := myType.mgoCollection.Insert(msg)
if err != nil {
    myType.mgoSession = myType.mgoSession.Copy()
    myType.mgoCollection = myType.mgoSession.DB("my_db_name").C("my_collection_name")
}

and re-submit. Sometimes this is enough, sometimes several retries are needed. And sometimes even after 10 retries (each around 1 minute) the error is still there (currently I break up after 10 retries).

I could not find anything suspicious in the mongodb logs and do not know where to look further.

Most of my writes to mongo are rather small, but twice a second there are somewhat larger writes (maybe 1 or 10 kb when represented as JSON string).

I have two separate processes and this error occurs for both of them at the same time.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题