"master has changed"

480 views
Skip to first unread message

Ted

unread,
Mar 2, 2011, 10:50:09 AM3/2/11
to mongodb-user
Hi everybody.

I've got a small setup of mongo using a replica set. No auto-sharding,
no mongos. Just three mongod instances (two nodes and one arbiter).

However, when I connect to do a find, I get an exception on "master
has changed." I've included the code and the output. Any idea what I'm
doing wrong?

I'm using pymongo from yesterday's git (1.9+). Mongod version below:

$ mongod --version
db version v1.6.0, pdfile version 4.5
Wed Mar 2 10:49:12 git version:
2c7f164b653f0d703947572ede064aed41cc2185


# === blah.py ====
import pymongo
print "Version", pymongo.version
servers = "mongodb://localhost:27017,localhost:27018,localhost:27019/?
slaveok=true"
DBNAME = "my-db"
COLLECTION = "User"
con = pymongo.Connection(servers)
db = con[DBNAME]
collection = db[COLLECTION]

for x in collection.find():
print x

# === running it from the shell ====

$ python blah.py
Version 1.9+
Traceback (most recent call last):
File "blah.py", line 10, in <module>
for x in collection.find():
File "/Library/Python/2.6/site-packages/pymongo/cursor.py", line
601, in next
if len(self.__data) or self._refresh():
File "/Library/Python/2.6/site-packages/pymongo/cursor.py", line
564, in _refresh
self.__query_spec(), self.__fields))
File "/Library/Python/2.6/site-packages/pymongo/cursor.py", line
533, in __send_message
self.__tz_aware)
File "/Library/Python/2.6/site-packages/pymongo/helpers.py", line
98, in _unpack_response
raise AutoReconnect("master has changed")
pymongo.errors.AutoReconnect: master has changed

Bernie Hackett

unread,
Mar 2, 2011, 1:48:58 PM3/2/11
to mongodb-user
I just tested this out using your code and can't reproduce the
problem. The difference between my environment and yours is I have one
primary and two secondaries instead of one secondary and an arbiter. I
even killed the primary so that a new secondary was elected and ran a
bunch of queries without creating a new connection instance.

A couple of things to note:

1. You say you have one primary, one secondary and an arbiter. Your
mongodb URI shouldn't list the arbiter.

2. You are running a pretty old version of mongodb. 1.6.5 is the most
recent stable release.

I'm going to retry the my test using the same mongo version and the
exact same setup. I'll let you know what I find.

Ted Roden

unread,
Mar 2, 2011, 1:55:10 PM3/2/11
to mongod...@googlegroups.com


1. You say you have one primary, one secondary and an arbiter. Your
mongodb URI shouldn't list the arbiter.

That seems to be the problem! I just removed it and it was fine. 


2. You are running a pretty old version of mongodb. 1.6.5 is the most
recent stable release.

I'll look into upgrading. 
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Bernie Hackett

unread,
Mar 2, 2011, 2:05:47 PM3/2/11
to mongodb-user
> That seems to be the problem! I just removed it and it was fine.

Great!

I'm going to open a ticket about pymongo trying to run queries against
an arbiter. When it auto-discovers the nodes in a replica set it
should throw out invalid entries or raise an exception.

Bernie Hackett

unread,
Mar 2, 2011, 2:34:40 PM3/2/11
to mongodb-user
Reply all
Reply to author
Forward
0 new messages