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

Empty read preference tag sets are incorrectly skipped during command construction

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.7.4
    • Affects Version/s: None
    • Component/s: None
    • None

      When creating read preference documents for commands, the driver skips empty tag sets here. However, per the server selection spec, an empty tag set is semantically important:

      A tag set that is an empty document matches any server, because the empty tag set is a subset of any tag set. This means the default tag_sets parameter ([{}]) matches all servers.

      Empty tag sets can be used as a fallback to match any server if previous tag sets did not match. The driver's skip behavior causes issues when connected to sharded clusters because the empty tag set will not be included in the $readPreference document, so the mongos will return a FailedToSatisfyReadPreference error if no servers matched the previous sets.

      I've attached Go and Python versions of a script that demonstrates this issue. If connected to a sharded cluster with a mongos running on localhost:27017, the Go script fails and the Python one succeeds.

        1. main.py
          0.4 kB
        2. main.go
          1 kB

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: