Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2305

Empty readPreferenceTags Connection Failure

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.8.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed

      Summary

      Per docs (https://docs.mongodb.com/manual/core/read-preference-tags), an empty tag can be used as a "fail-safe" mechanism  to connect to any node regardless of tag:

      "To avoid an error if no members match any of the tag specifications, you can add an empty document {{{ }}} as the last element of the tag set to read from any eligible member."

      However, when using "readPreferenceTag=" as the last tag set in the connection URI the driver fails to send an empty document in the tag array.  I found a commit (https://github.com/mongodb/mongo-go-driver/commit/bfd961abf162856d6dc7c6d97ec627c18e1ceed0) that seems to simply break instead of treating as an empty document.

      How to Reproduce

      1. Standup replica set and provide any tag (ex: {dc: dev} )
      2. Try to connect with URI containing mismatched tag, but with empty tag as a "fail-safe" (ex: ?readPreferenceTag=dc:prod&readPreferenceTag=)
      3. Connection will fail

            Assignee:
            benji.rewis@mongodb.com Benji Rewis (Inactive)
            Reporter:
            john08burke John Burke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: