Question

I'm working in a apps where I'm using mongodb with replicaset.

In my replicaset I've 2 db servers and 1 arbiter. I'm creating my mongo object as follows

List<ServerAddress> servers = new ArrayList<ServerAddress>();
servers.add( new ServerAddress( "192.168.1.42", 27017 ) );
servers.add( new ServerAddress( "192.168.1.187", 27017 ) );
servers.add( new ServerAddress( "192.168.1.189", 27017 ) ); //Arbiter

MongoOptions mongoOptions = new MongoOptions();
mongoOptions.autoConnectRetry = true;
mongo = new Mongo(servers, mongoOptions);
mongo.slaveOk();

When all the servers are up then there are no problems but when any one of the server goes down the system starts to through endless error messages as shown below

May 17, 2011 11:24:19 AM com.mongodb.ReplicaSetStatus$Node update
SEVERE: can't update node: 192.168.1.42:27017
java.io.IOException: couldn't connect to [/192.168.1.42:27017] bc:java.net.ConnectException: Connection refused: connect
    at com.mongodb.DBPort._open(DBPort.java:206)
    at com.mongodb.DBPort.go(DBPort.java:94)
    at com.mongodb.DBPort.go(DBPort.java:75)
    at com.mongodb.DBPort.findOne(DBPort.java:129)
    at com.mongodb.DBPort.runCommand(DBPort.java:138)
    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)

Can you help me to resolve this?

Since I'm using a replica set, if one server is down isn't suppose to use the new primary and ignore the older primary?

Please find the below images to check the replica set status

All servers up and 192.168.1.42 is the primary server enter image description here

192.168.1.42 is down(manually teminated) and 192.168.1.187 is the new primary(The errors happens now) enter image description here

192.168.1.42 is up again and actings as a secondary server(error goes off) enter image description here

UPDATED: The database works even if the error messages get logged. Is there a mechanism to reduce/suppress the error messages?

Was it helpful?

Solution

This is a logging issue. It is now a warning, instead of an error.

The 2.6 driver (due out later this week) will be less verbose with logging for this. This is not an error but just a warning that that node is down when the background thread checks on the status of the replicaset members. You can use the current version in master if you want to test now: http://github.com/mongodb/mongo-java-driver

http://github.com/mongodb/mongo-java-driver/commit/ee7543a4f7cc26618cf78eab2a18bd33b3e101cc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top