Option parsing does not properly handle replica set members with different ports

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Tools and Replicator
    • 0

      Problem Statement/Rationale

      When connecting using a mongodb+srv URL where the SRV records point at replica set members on different ports, options parsing sets the Port option to the first port found and then assumes all other members are on the same port. It should instead leave the port number in the returned list of Hosts and not set the Port option.

      Steps to Reproduce

      Set up a replica set with three members, at least one of which is on a different port than the others. Create appropriate SRV records to point at the replica set members. Try connecting with `mongostat -vvvvv mongodb+srv://...`.

      Expected Results

      mongostat should properly discover and connect to the replica set members.

      Actual Results

      In the verbose output from mongostat, the lines "adding new host to monitoring: " show the correct hostnames, however they all use the same port even though at least one member is using a different port. This prevents mongostat from fully connecting and it never displays stats. It may also throw a TLS certificate error or authentication error if it accidentally connects to a different MongoDB replica set running on the same hostname but wrong port.

      Additional Notes

      Please see https://github.com/mongodb/mongo-tools/compare/master...magglass1:mongo-tools:multiport_fix for a proposed fix. This would need to be tested more extensively, but it does resolve the issue when running mongostat against an affected replica set using the mongodb+srv:// URI.

            Assignee:
            Unassigned
            Reporter:
            Mark Lessel (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: