Loss and recovery connections to database

Skip to first unread message


Jan 27, 2017, 9:50:15 AM1/27/17
to mgo-users
Hello Gustavo,

We have the golang web-application for distribution a lot of traffic. Our data stored in mongodb with replicaset: arbiter, master and two slave. Throughput over 1000 requests per seconds. And we have some troubles with the connection to database

For each request we copy session, source code is here

Sometimes we lose connection for one node, and by reconnection we lose many traffic. The connection breaking occurs with error like: read tcp> i/o timeout or Closed explicitly.  Why we lose connection? So if one node is not available, mgo must connect to another mongodb nodes without loss traffic? newSession.LiveServers() shows available nodes at the crash moment. 

Can you help us, maybe the code need change?


Mar 17, 2017, 8:23:14 AM3/17/17
to mgo-users
Same issue only appearing wth high throughput.

We tried copying session and not doing it. Same issue.

We tried recovering the socket panic "i/o timeout" and Dial again, but "no reachable servers" is thrown. Trying to get server back in the pool, now... will update if I find a solution.

İnanç Gümüş

Jul 31, 2017, 4:58:48 PM7/31/17
to mgo-users
I just simply set `session.SetPoolLimit(50)` and errors went away.

17 Mart 2017 Cuma 15:23:14 UTC+3 tarihinde juan.he...@exoclick.com yazdı:

Gustavo Niemeyer

Aug 3, 2017, 6:18:00 AM8/3/17
to mgo-...@googlegroups.com
Hi again,

Per notes in the issue you filed, that prevents the timeout because it will greatly constraint the number of resources used by mgo and the database. It will do that by forcing arbitrary waiting on any database operation, which is incorrect in pretty much all cases. Please see the docs for SetPoolLimit. Using it is pretty much never right, unless you are increasing the limit because you have more resources available.

For constraining, do so "at the door", at a place that has a better idea about what to do with excess demand that cannot be handled by your infrastructure.

You received this message because you are subscribed to the Google Groups "mgo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mgo-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
0 new messages