Mongodb replication issue

47 views
Skip to first unread message

Baskar Lakshmi

unread,
Dec 1, 2016, 2:47:27 PM12/1/16
to mongodb-user
 
 

I have the issue. I've noticed this happens to applications with a high writing rate. In other words, if your application is trying to make too many write operations while the primary is down, it will eventually throw the "connection closed" error.Kindly advice pls find the below connection string which i used


mongodb://192.168.XX.XX:27017,192.168.XX.XX:27017,192.168.XX.XX:27017/?replicaSet=rs0

Jojie Palahang

unread,
Dec 5, 2016, 11:44:47 PM12/5/16
to mongodb-user
Hi bro, can you provide a document how to replicate this issue, i was also curious what could be root cause of this.

what i have is a replicate set in virtual box + docker, soo far i don't have issues like this.

Kevin Adistambha

unread,
Dec 15, 2016, 8:51:05 PM12/15/16
to mongodb-user

Hi Baskar

if your application is trying to make too many write operations while the primary is down, it will eventually throw the “connection closed” error.

This is by design, since there are many possible types of write operations (e.g. update whole documents, incrementing field, etc.) that could have different strategies on how to retry a write. If a failover happens while a write is ongoing, the driver does not retry the write by itself, since it could potentially create corrupt data if it choose the wrong retry strategy. Rather, the driver will throw an exception, letting the application know that an operation has failed due to network issues, try to reconnect to the replica set automatically, while leaving the retry strategy to the application.

In pymongo, there is an example on how to handle this exception in High Availability and PyMongo

For some background on why this approach is preferred, see:

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages