Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-1750

Unexpected behavior when specifying host and port with list of hosts

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      from github 102:

      Hi,

      I'm doing the following call mongodump --host db1:27011,db2:27011,db3,db4 --port 4444.
      I found out the hard way: If db3 and db4 are not reachable mongodump is not working any more: error connecting to db server: no reachable servers

      I traced it down to the following line https://github.com/mongodb/mongo-tools/blob/29b8883c560319b016f8bd4927807fa36f1a682f/common/util/mongo.go#L49
      where the --port is unconditionally added to every host entry. So when db3 and db4 were not reachable he tried to connect db1:27011:4444 which is obviously wrong.

      It would be gread if mongodump would behave like pymongo, which is.
      Only if not port is given you she one specified in the port option.

      https://github.com/mongodb/mongo-python-driver/blob/75b2b1fc41a7126c4e719eb73ff4656c9defdc2e/pymongo/mongo_client.py#L431

      https://github.com/mongodb/mongo-python-driver/blob/75b2b1fc41a7126c4e719eb73ff4656c9defdc2e/pymongo/uri_parser.py#L128

            Assignee:
            david.golden@mongodb.com David Golden
            Reporter:
            william.banfield William Banfield
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: