Hi,
I'm using the mongodb java driver 2.5.3 in a spring application. We have a mongodb replica set consisting of a mongodb master and one slave (both of version 1.8.0). Within a junit test i start many threads performing mainly some 'findAndModify' operations. To connect to this replica set each thread creates and uses its own Mongo instance.
Each Mongo instances uses the following options:
autoConnectRetry=false
connectionsPerHost=5
threadsAllowedToBlockForConnectionMultiplier=20
connectTimeout=2000
maxWaitTime=2000
socketTimeout=2000
socketKeepAlive=false
slaveOk=false
safe=true
w=1
wtimeout=0
fsync=false
replicaSet=
192.168.0.141:27017,
192.168.0.136:27017... and is instantiated with: new Mongo(replicaSetAsServerAddressList, mongoOptions);
The more i increase the number of threads the higher is the probability that exceptions of the following type occur:
14.04.2011 13:30:29 com.mongodb.ReplicaSetStatus$Node update
FATAL: can't update node:
192.168.0.141:27017java.lang.IllegalArgumentException: need a connector: admin
at com.mongodb.DBApiLayer.<init>(DBApiLayer.java:86)
at com.mongodb.Mongo.getDB(Mongo.java:319)
at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149)
at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314)
at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:263)
The problem is still present when i play with different MongoOptions.
When i use only one mongo instance for all threads no problems occur. When i use no replica set but only a single mongo master no problems occur even if i use different Mongo instances (each created with: new Mongo(serverAddress, MongoOptions)).
The Question is - is this expected behavior? Is it in my case not allowed to use different Mongo instances within a jvm?
Best Regards,
Michael