Question What is the best way to deal with this error? Try again, say, 30 seconds for max. 5 times?
Settings I have PRIMARY + two SECONDARY settings on AWS ECS, and none of them have been disabled.
From the exception message, it seems that Mongo says: “I have NO BASE, and I tried to get data from SECONDARY, but they are too much.” But none of the Mongo servers were shut down. I had another process that has read_preference by default SECONDARY and works fine.
Exception
is_auth = db.authenticate("myid","mypass") File "/usr/local/lib/python2.7/dist-packages/pymongo/database.py", line 720, in authenticate read_preference=read_pref)["nonce"] File "/usr/local/lib/python2.7/dist-packages/pymongo/database.py", line 390, in command result = self["$cmd"].find_one(command, **extra_opts) File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 598, in find_one for result in self.find(spec_or_id, *args, **kwargs).limit(-1): File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 814, in next if len(self.__data) or self._refresh(): File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 763, in _refresh self.__uuid_subtype)) File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 700, in __send_message **kwargs) File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_replica_set_client.py ", line 1210, in _send_message_with_response raise AutoReconnect(msg, errors) AutoReconnect: No replica set members available for query with ReadPreference PRIMARY_PREFERRED
code
connection = MongoReplicaSetClient(, replicaSet='myReplica-2', use_greenlets = True) db = "my_real_db" db.read_preference = ReadPreference.PRIMARY is_auth = db.authenticate("myid", "mypass") # ERROR at this line
MongoDB Version : 2.2.0 and PyMongo: 2.4.2