Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3439

When nodes from multiple replica set in the URI, driver picks the replica set at random

    • Type: Icon: New Feature New Feature
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Connection Management
    • Labels:
      None

      Seen this in 3.11.0 and some older versions.
      When creating connection to replica sets:

      • using non-SRV uri
      • seed list(must include all primaries) from multiple replica sets in the URI
      • replica set names are the same
      • same user credentials can access all replica sets

      The driver will try connect to all seeds in the list and pick whichever replica set seemingly randomly.

      It should throw an error and stop executing if the seed list contains nodes from multiple replica sets.

      See example:

      ubuntu@javahost:~/tour$ java -cp ./target/tour-1.0-SNAPSHOT.jar com.tour.QuickTour
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Cluster created with settings {hosts=[cluster0-shard-00-00-r6suh.mongodb.net:27017, cluster0-shard-00-00-ukz0p.mongodb.net:27017, cluster0-shard-00-01-r6suh.mongodb.net:27017, cluster0-shard-00-02-r6suh.mongodb.net:27017, cluster0-shard-00-02-ukz0p.mongodb.net:27017], mode=MULTIPLE, requiredClusterType=REPLICA_SET, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500, requiredReplicaSetName='Cluster0-shard-0'}
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Adding discovered server cluster0-shard-00-00-r6suh.mongodb.net:27017 to client view of cluster
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Adding discovered server cluster0-shard-00-00-ukz0p.mongodb.net:27017 to client view of cluster
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Adding discovered server cluster0-shard-00-01-r6suh.mongodb.net:27017 to client view of cluster
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Adding discovered server cluster0-shard-00-02-r6suh.mongodb.net:27017 to client view of cluster
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Adding discovered server cluster0-shard-00-02-ukz0p.mongodb.net:27017 to client view of cluster
      Sep 17, 2019 3:38:15 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: No server chosen by com.mongodb.client.internal.MongoClientDelegate$1@4bbfb90a from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, serverDescriptions=[ServerDescription{address=cluster0-shard-00-00-r6suh.mongodb.net:27017, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=cluster0-shard-00-01-r6suh.mongodb.net:27017, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=cluster0-shard-00-02-r6suh.mongodb.net:27017, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=cluster0-shard-00-02-ukz0p.mongodb.net:27017, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=cluster0-shard-00-00-ukz0p.mongodb.net:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:3, serverValue:80729}] to cluster0-shard-00-01-r6suh.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:4, serverValue:5813}] to cluster0-shard-00-00-r6suh.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:2, serverValue:7804}] to cluster0-shard-00-02-r6suh.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:5, serverValue:618}] to cluster0-shard-00-00-ukz0p.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:1, serverValue:941}] to cluster0-shard-00-02-ukz0p.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Monitor thread successfully connected to server with description ServerDescription{address=cluster0-shard-00-02-ukz0p.mongodb.net:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 14]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=100551200, setName='Cluster0-shard-0', canonicalAddress=cluster0-shard-00-02-ukz0p.mongodb.net:27017, hosts=[cluster0-shard-00-02-ukz0p.mongodb.net:27017, cluster0-shard-00-01-ukz0p.mongodb.net:27017, cluster0-shard-00-00-ukz0p.mongodb.net:27017], passives=[], arbiters=[], primary='cluster0-shard-00-00-ukz0p.mongodb.net:27017', tagSet=TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, electionId=null, setVersion=1, lastWriteDate=Tue Sep 17 15:38:16 GMT 2019, lastUpdateTimeNanos=52532919187839}
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Monitor thread successfully connected to server with description ServerDescription{address=cluster0-shard-00-02-r6suh.mongodb.net:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 14]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=111580900, setName='Cluster0-shard-0', canonicalAddress=cluster0-shard-00-02-r6suh.mongodb.net:27017, hosts=[cluster0-shard-00-02-r6suh.mongodb.net:27017, cluster0-shard-00-01-r6suh.mongodb.net:27017, cluster0-shard-00-00-r6suh.mongodb.net:27017], passives=[], arbiters=[], primary='cluster0-shard-00-01-r6suh.mongodb.net:27017', tagSet=TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, electionId=null, setVersion=1, lastWriteDate=Tue Sep 17 15:38:08 GMT 2019, lastUpdateTimeNanos=52532919137039}
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Monitor thread successfully connected to server with description ServerDescription{address=cluster0-shard-00-00-r6suh.mongodb.net:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 14]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=97295800, setName='Cluster0-shard-0', canonicalAddress=cluster0-shard-00-00-r6suh.mongodb.net:27017, hosts=[cluster0-shard-00-02-r6suh.mongodb.net:27017, cluster0-shard-00-01-r6suh.mongodb.net:27017, cluster0-shard-00-00-r6suh.mongodb.net:27017], passives=[], arbiters=[], primary='cluster0-shard-00-01-r6suh.mongodb.net:27017', tagSet=TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, electionId=null, setVersion=1, lastWriteDate=Tue Sep 17 15:38:08 GMT 2019, lastUpdateTimeNanos=52532914239339}
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Monitor thread successfully connected to server with description ServerDescription{address=cluster0-shard-00-01-r6suh.mongodb.net:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 14]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=117566800, setName='Cluster0-shard-0', canonicalAddress=cluster0-shard-00-01-r6suh.mongodb.net:27017, hosts=[cluster0-shard-00-02-r6suh.mongodb.net:27017, cluster0-shard-00-01-r6suh.mongodb.net:27017, cluster0-shard-00-00-r6suh.mongodb.net:27017], passives=[], arbiters=[], primary='cluster0-shard-00-01-r6suh.mongodb.net:27017', tagSet=TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, electionId=7fffffff0000000000000008, setVersion=1, lastWriteDate=Tue Sep 17 15:38:08 GMT 2019, lastUpdateTimeNanos=52532919651639}
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Monitor thread successfully connected to server with description ServerDescription{address=cluster0-shard-00-00-ukz0p.mongodb.net:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 14]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=99622600, setName='Cluster0-shard-0', canonicalAddress=cluster0-shard-00-00-ukz0p.mongodb.net:27017, hosts=[cluster0-shard-00-02-ukz0p.mongodb.net:27017, cluster0-shard-00-01-ukz0p.mongodb.net:27017, cluster0-shard-00-00-ukz0p.mongodb.net:27017], passives=[], arbiters=[], primary='cluster0-shard-00-00-ukz0p.mongodb.net:27017', tagSet=TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, electionId=7fffffff0000000000000001, setVersion=1, lastWriteDate=Tue Sep 17 15:38:16 GMT 2019, lastUpdateTimeNanos=52532909546239}
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Adding discovered server cluster0-shard-00-01-ukz0p.mongodb.net:27017 to client view of cluster
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Server cluster0-shard-00-00-r6suh.mongodb.net:27017 is no longer a member of the replica set.  Removing from client view of cluster.
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Server cluster0-shard-00-01-r6suh.mongodb.net:27017 is no longer a member of the replica set.  Removing from client view of cluster.
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Server cluster0-shard-00-02-r6suh.mongodb.net:27017 is no longer a member of the replica set.  Removing from client view of cluster.
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Setting max election id to 7fffffff0000000000000001 from replica set primary cluster0-shard-00-00-ukz0p.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Setting max set version to 1 from replica set primary cluster0-shard-00-00-ukz0p.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Discovered replica set primary cluster0-shard-00-00-ukz0p.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:6, serverValue:568}] to cluster0-shard-00-01-ukz0p.mongodb.net:27017
      Sep 17, 2019 3:38:17 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Monitor thread successfully connected to server with description ServerDescription{address=cluster0-shard-00-01-ukz0p.mongodb.net:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 14]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=98244200, setName='Cluster0-shard-0', canonicalAddress=cluster0-shard-00-01-ukz0p.mongodb.net:27017, hosts=[cluster0-shard-00-02-ukz0p.mongodb.net:27017, cluster0-shard-00-01-ukz0p.mongodb.net:27017, cluster0-shard-00-00-ukz0p.mongodb.net:27017], passives=[], arbiters=[], primary='cluster0-shard-00-00-ukz0p.mongodb.net:27017', tagSet=TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, electionId=null, setVersion=1, lastWriteDate=Tue Sep 17 15:38:16 GMT 2019, lastUpdateTimeNanos=52533641439439}
      Sep 17, 2019 3:38:18 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Opened connection [connectionId{localValue:7, serverValue:619}] to cluster0-shard-00-00-ukz0p.mongodb.net:27017
      {"_id": {"$oid": "5d80fdeac6a6802059b15392"}, "name": "MongoDB", "type": "database", "count": 1, "info": {"x": 203, "y": 102}}
      total # of documents : 11
      {"_id": {"$oid": "5d80fdeac6a6802059b15392"}, "name": "MongoDB", "type": "database", "count": 1, "info": {"x": 203, "y": 102}}
      {"_id": {"$oid": "5d80fdeac6a6802059b15393"}, "i": 0}
      {"_id": {"$oid": "5d80fdeac6a6802059b15394"}, "i": 1}
      {"_id": {"$oid": "5d80fdeac6a6802059b15395"}, "i": 2}
      {"_id": {"$oid": "5d80fdeac6a6802059b15396"}, "i": 3}
      {"_id": {"$oid": "5d80fdeac6a6802059b15397"}, "i": 4}
      {"_id": {"$oid": "5d80fdeac6a6802059b15398"}, "i": 5}
      {"_id": {"$oid": "5d80fdeac6a6802059b15399"}, "i": 6}
      {"_id": {"$oid": "5d80fdeac6a6802059b1539a"}, "i": 7}
      {"_id": {"$oid": "5d80fdeac6a6802059b1539b"}, "i": 8}
      {"_id": {"$oid": "5d80fdeac6a6802059b1539c"}, "i": 9}
      {"_id": {"$oid": "5d80fdeac6a6802059b15396"}, "i": 3}
      {"_id": {"$oid": "5d80fdeac6a6802059b1539c"}, "i": 9}
      {"name": "MongoDB", "type": "database", "count": 1, "info": {"x": 203, "y": 102}}
      Sep 17, 2019 3:38:20 PM com.mongodb.diagnostics.logging.JULLogger log
      INFO: Closed connection [connectionId{localValue:7, serverValue:619}] to cluster0-shard-00-00-ukz0p.mongodb.net:27017 because the pool has been closed.
      ubuntu@javahost:~/tour$
      

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jennifer.huang@mongodb.com Jennifer Huang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: