|
Ah sorry, for the test I ran locally I realized that I was passing localhost instead of the hostname that matches the rs.conf(). I tried a new test specifying set tags and got some more logs I did not get before.
Using "localhost" instead of the hostname seems to reject the servers from the cluster view and then eventually is left with just the arbiter.
INFO: Server localhost:27017 is no longer a member of the replica set. Removing from client view of cluster.
|
Dec 30, 2016 2:36:42 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Server localhost:27018 is no longer a member of the replica set. Removing from client view of cluster.
|
Dec 30, 2016 2:36:42 PM com.mongodb.diagnostics.logging.JULLogger log
|
At this point the driver seems to try to connect to the arbiter and then times out:
INFO: Monitor thread successfully connected to server with description ServerDescription{address=roys-macbook-pro-2.local:27018, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 4]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, roundTripTimeNanos=1122940, setName='replset', canonicalAddress=Roys-MacBook-Pro-2.local:27018, hosts=[Roys-MacBook-Pro-2.local:27017, Roys-MacBook-Pro-2.local:27018], passives=[], arbiters=[Roys-MacBook-Pro-2.local:27019], primary='Roys-MacBook-Pro-2.local:27017', tagSet=TagSet{[Tag{name='use', value='pickme'}]}, electionId=null, setVersion=2, lastWriteDate=null, lastUpdateTimeNanos=253536488493318}
|
Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=ReadPreference{name=nearest, tagSetList=[TagSet{[Tag{name='pick', value='useme'}]}]}}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=roys-macbook-pro-2.local:27017, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='use', value='pickme'}]}, roundTripTime=0.9 ms, state=CONNECTED}, {address=roys-macbook-pro-2.local:27018, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='use', value='pickme'}]}, roundTripTime=1.0 ms, state=CONNECTED}, {address=roys-macbook-pro-2.local:27019, type=REPLICA_SET_ARBITER, roundTripTime=0.9 ms, state=CONNECTED}]
|
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:377)
|
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:104)
|
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
|
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
|
at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
|
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:402)
|
at com.mongodb.operation.FindOperation.execute(FindOperation.java:510)
|
at com.mongodb.operation.FindOperation.execute(FindOperation.java:81)
|
at com.mongodb.Mongo.execute(Mongo.java:836)
|
at com.mongodb.Mongo$2.execute(Mongo.java:823)
|
Which is still odd behavior to me. If I fix my connection string to use the same hostnames in my rs.config() then all works as expected.
Now that I know that I'm not using the right hostname I tried again but when I include the arbiter back into the connection string I was still able to get the error again.
Roys-MacBook-Pro-2:MongoDBJava royrim$ java -cp lib/*:dist/MongoDBJava.jar mongodbjava.MongoDBJava "mongodb://user:password@Roys-MacBook-Pro-2.local:27017,Roys-MacBook-Pro-2.local:27018,Roys-MacBook-Pro-2.local:27019/?authSource=admin&replicaSet=replset&readPreference=nearest"
|
Dec 30, 2016 2:57:44 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Cluster created with settings {hosts=[roys-macbook-pro-2.local:27017, roys-macbook-pro-2.local:27018, roys-macbook-pro-2.local:27019], mode=MULTIPLE, requiredClusterType=REPLICA_SET, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500, requiredReplicaSetName='replset'}
|
Dec 30, 2016 2:57:44 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Adding discovered server roys-macbook-pro-2.local:27017 to client view of cluster
|
Dec 30, 2016 2:57:44 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Adding discovered server roys-macbook-pro-2.local:27018 to client view of cluster
|
Dec 30, 2016 2:57:44 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Adding discovered server roys-macbook-pro-2.local:27019 to client view of cluster
|
Dec 30, 2016 2:57:45 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: No server chosen by ReadPreferenceServerSelector{readPreference=ReadPreference{name=nearest}} from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, serverDescriptions=[ServerDescription{address=roys-macbook-pro-2.local:27017, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=roys-macbook-pro-2.local:27018, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=roys-macbook-pro-2.local:27019, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
|
Dec 30, 2016 2:57:45 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Opened connection [connectionId{localValue:3, serverValue:82}] to roys-macbook-pro-2.local:27019
|
Dec 30, 2016 2:57:45 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Monitor thread successfully connected to server with description ServerDescription{address=roys-macbook-pro-2.local:27019, type=REPLICA_SET_ARBITER, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 4]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, roundTripTimeNanos=5604590, setName='replset', canonicalAddress=Roys-MacBook-Pro-2.local:27019, hosts=[Roys-MacBook-Pro-2.local:27017, Roys-MacBook-Pro-2.local:27018], passives=[], arbiters=[Roys-MacBook-Pro-2.local:27019], primary='Roys-MacBook-Pro-2.local:27017', tagSet=TagSet{[]}, electionId=null, setVersion=2, lastWriteDate=null, lastUpdateTimeNanos=254799123231338}
|
Dec 30, 2016 2:57:45 PM com.mongodb.diagnostics.logging.JULLogger log
|
INFO: Opened connection [connectionId{localValue:4, serverValue:83}] to roys-macbook-pro-2.local:27019
|
Exception in thread "main" com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized on test to execute command { find: "blah", filter: { name: "roy" } }' on server roys-macbook-pro-2.local:27019
|
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:521)
|
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:510)
|
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:431)
|
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:404)
|
at com.mongodb.operation.FindOperation.execute(FindOperation.java:510)
|
at com.mongodb.operation.FindOperation.execute(FindOperation.java:81)
|
at com.mongodb.Mongo.execute(Mongo.java:836)
|
at com.mongodb.Mongo$2.execute(Mongo.java:823)
|
at com.mongodb.OperationIterable.iterator(OperationIterable.java:47)
|
at com.mongodb.FindIterableImpl.iterator(FindIterableImpl.java:151)
|
at mongodbjava.MongoDBJava.main(MongoDBJava.java:48)
|
Roy
|