luocheng
unread,Aug 13, 2012, 8:03:19 AM8/13/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongod...@googlegroups.com
Hi all
i want to autoreconnect to mongodb when some fails happen to mongodb replicatesets,the code of connection is as bellow:
self.db_connection = ReplicaSetConnection("localhost:7017", replicaSet='nova_data')
self.db_database = self.db_connection[self.db_name]
there are 10 processes writing some info to mongodb every 30 seconds,
when i shutdown the primary , relicate set elect the new primary , but the write process write to mongodb successfully some times,
and then fail some times,and successfully some times again.
in fact ,it has already connect to the new primary ,but it will raise autoreconnection errors some times.
what's the reason ?
should i reassgin the self.db_database after the autoreconnection happens? how can i avoid the failure when autoreconnection happens?
PS: i use pymongo 2.1,mongodb 2.0.1