Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-316

Handle MongoDB connection string format differently than legacy format

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • legacy-1.0.0-rc1
    • Affects Version/s: legacy-1.0.0-rc0
    • Component/s: API
    • Environment:
      All

      ConnectionString::parse currently falls back to allowing an alternate internal mongodb connection format that can be parsed and considered valid by isValid() but do the wrong thing when connecting (which is surprising for the user).

      An example of this is the following url:

      localhost:1050,localhost:1055,localhost:1056/?replicaSet=rs-83d7523f-16cf-4246-8014-f1a6fa7ec264

      It doesn't start with a mongodb:// so it's parsed in classic mode which creates the following observable behavior on the resulting connection string:

      • isValid() returns true
      • getServers() returns: replicaSet=rs-83d7523f-16cf-4246-8014-f1a6fa7ec264:27017 which is essentially the replica set portion
      • getSetName returns: "localhost:1050,localhost:1055,localhost:1056" which is essentially the servers portion
      • connect() fails with: "connect failed to replica set localhost:1050,localhost:1055,localhost:1056/?replicaSet=rs-83d7523f-16cf-4246-8014-f1a6fa7ec264:27017"

      I am proposing that we split the functionality by having

      • ConnectionString::parse accept only valid MongoDB connection strings
      • Another parsing function to handle the odd deprecated internal format

      We can also probably throw if there is no match in the new function now that we don't support the older version of the api.

            Assignee:
            samantha.ritter@mongodb.com Samantha Ritter (Inactive)
            Reporter:
            tyler@10gen.com Tyler Brock
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: