Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-20743

Sharding code needs to set $secondaryOk on commands targeted at hosts via read preferences other than PrimaryOnly.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.9
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Sharding A (10/09/15)

      The runCommand methods on the ShardRegistry type that currently take a HostAndPort argument should actually take a ReadPreferenceSetting and either a Shard or a Targeter. The problem with the current form is that the targeter is given a read preference by code trying to run commands against shards in order to derive a HostAndPort. The code trying to run commands is not then obligated (or sometimes even enabled) to appropriately set the $secondaryOk metadata field. Given the uses, a better design would be for the runCommand-like methods to take a Shard or Targeter along with a read preference, and to do targeting and command dispatch together.

      Making this change will hopefully eliminate bugs where operations are targeted to secondary nodes without setting the $secondaryOk flag.

            Assignee:
            schwerin@mongodb.com Andy Schwerin
            Reporter:
            schwerin@mongodb.com Andy Schwerin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: