jvm 1 | 2011/04/02 21:25:33 | Apr 2, 2011 9:25:33 PM
com.mongodb.ReplicaSetStatus$Node update
jvm 1 | 2011/04/02 21:25:33 | SEVERE: can't update node: 127.0.0.1:27017
jvm 1 | 2011/04/02 21:25:33 | java.lang.IllegalArgumentException:
need a connector: admin
jvm 1 | 2011/04/02 21:25:33 | at
com.mongodb.DBApiLayer.<init>(DBApiLayer.java:86)
jvm 1 | 2011/04/02 21:25:33 | at com.mongodb.Mongo.getDB(Mongo.java:319)
jvm 1 | 2011/04/02 21:25:33 | at
com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149)
jvm 1 | 2011/04/02 21:25:33 | at
com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314)
jvm 1 | 2011/04/02 21:25:33 | at
com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:263)
After this happens, the Mongo instance seems to be working fine so I
am not sure what it is. There is nothing out of the ordinary in the
mongod console.
The debugString() from the Mongo instance is "DBTCPConnector: replica
set : [127.0.0.1:27017]"
I am running Mongo 1.8.0. The Java driver is 2.5.2.
Do you have any idea what could be causing this? Please let me know
if there is any other information I can provide.
Thanks in advance,
Leif
The Mongo instance is set up with code like the following. Simplified
to remove our config parsing.
---
List<ServerAddress> serverAddresses = new ArrayList<ServerAddress>();
ServerAddress serverAddress = new ServerAddress( "127.0.0.1", 27017 );
serverAddresses.add( serverAddress );
MongoOptions options = new MongoOptions();
options.autoConnectRetry = true;
options.connectionsPerHost = 10;
options.threadsAllowedToBlockForConnectionMultiplier = 5;
options.maxWaitTime = 120000;
options.connectTimeout = 0;
options.socketTimeout = 0;
m_mongo = new Mongo( serverAddresses, options );
m_mongo.slaveOk();
m_db = m_mongo.getDB( "myapp" );
CommandResult result = m_db.command( "ismaster" );
System.out.println( result );
---
We currently only have a single server running.
The output of the above is:
---
{ "ismaster" : true , "maxBsonObjectSize" : 16777216 , "ok" : 1.0}
---
Cheers,
Leif
I have modified my code as follows:
---
if ( serverAddresses.size() == 1 )
{
// This constructor puts the Mongo instance into
single server mode.
m_mongo = new Mongo( serverAddresses.get( 0 ), options );
}
else
{
// This constructor puts the Mongo instance into
replica set mode.
m_mongo = new Mongo( serverAddresses, options );
}
---
I'll give this a try for a while and see how it works.
The javadocs could probably use some more explanation to make their
behavior a bit clearer.
Thanks again,
Leif
jvm 1 | SEVERE: can't update node: test1.tsl.local:27017
jvm 1 | java.lang.IllegalArgumentException: need a connector: admin
jvm 1 | at com.mongodb.DBApiLayer.<init>(DBApiLayer.java:86)
jvm 1 | at com.mongodb.Mongo.getDB(Mongo.java:319)
jvm 1 | at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149)
jvm 1 | at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314)
jvm 1 | at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:263)
I am still using the 2.5.2 Java driver.
Do you have any ideas as to what might be causing this? The
application seems to work fine after this error has been logged.
Cheers,
Leif
On Sun, Apr 3, 2011 at 12:13 AM, Nat <nat....@gmail.com> wrote:
---
myapp:PRIMARY> rs.conf();
{
"_id" : "myapp",
"version" : 4,
"members" : [
{
"_id" : 0,
"host" : "myapp-test1.ttt.local:27017"
},
{
"_id" : 1,
"host" : "myapp-test2.ttt.local"
},
{
"_id" : 2,
"host" : "myapp-test3.ttt.local"
},
{
"_id" : 3,
"host" : "myapp-test4.ttt.local"
}
]
}
myapp:PRIMARY>
---
I am not sure why only the first host has the port. That was the
original one that I ran rs.initiate() on. Then I ran
rs.add("myapp-test2.ttt.local") for each of the other nodes.
I went through and double checked my mongodb.conf files and they all say:
replSet = myapp
Please let me know if there is anything else I can provide.
Cheers,
Leif
The nodes are also able to see eachother fine as can be seen from the
replicaset status regardless of which node is the master. I also
tried to resolve all hosts from all nodes manually just to be sure and
it all looks fine.
The error does not get dumped every time I start. This morning it was
almost every time, but now it is about 1 in 10 times. No idea what
changed there. When I was just doing the above test, I got a
slightly different error:
---
jvm 1 | Jun 1, 2011 5:43:30 PM com.mongodb.ReplicaSetStatus$Node update
jvm 1 | SEVERE: can't update node: myapp-test3.ttt.local:27017
jvm 1 | java.lang.IllegalArgumentException: need a connector: admin
jvm 1 | at com.mongodb.DBApiLayer.<init>(DBApiLayer.java:86)
jvm 1 | at com.mongodb.Mongo.getDB(Mongo.java:319)
jvm 1 | at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:149)
jvm 1 | at com.mongodb.ReplicaSetStatus.updateAll(ReplicaSetStatus.java:314)
jvm 1 | at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:263)
jvm 1 | Jun 1, 2011 5:43:30 PM com.mongodb.ReplicaSetStatus$Updater run
jvm 1 | WARNING: couldn't do update pass
jvm 1 | java.lang.NullPointerException
jvm 1 | at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:275)
---
Cheers,
Leif
---
List<ServerAddress> serverAddresses = new ArrayList<ServerAddress>();
serverAddresses.add( new ServerAddress( "myapp-test1.ttt.local", 27017 ) );
// Same if the following are also uncommented.
//serverAddresses.add( new ServerAddress( "myapp-test2.ttt.local", 27017 ) );
//serverAddresses.add( new ServerAddress( "myapp-test3.ttt.local", 27017 ) );
//serverAddresses.add( new ServerAddress( "myapp-test4.ttt.local", 27017 ) );
MongoOptions options = new MongoOptions();
options.autoConnectRetry = true;
options.connectionsPerHost = 10;
options.threadsAllowedToBlockForConnectionMultiplier = 5;
options.maxWaitTime = 120000;
options.connectTimeout = 0;
options.socketTimeout = 0;
m_mongo = new Mongo( serverAddresses, options );
m_mongo.slaveOk();
m_db = m_mongo.getDB( "myapp" );
---
Cheers,
Leif
Cheers,
Leif