Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-119

Mongos sharded replicaset read preference is not honored

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.4
    • Affects Version/s: 3.0.0
    • Component/s: None

      ReplSet: https://github.com/mongodb/node-mongodb-native/blob/1.4/lib/mongodb/connection/repl_set/repl_set.js#L161

      vs

      Server: https://github.com/mongodb/node-mongodb-native/blob/1.4/lib/mongodb/connection/server.js#L164

      Which is used in: https://github.com/mongodb/node-mongodb-native/blob/1.4/lib/mongodb/db.js#L262

      This causes readPreference variable to be missed out in the connect_options.

      I don't know if this is intended or not, but after adding: this.options.readPreference = this._readPreference = readPreference;

      I actually solved the problem and started to get reads from secondaries.

      If this is not a bug, please provide an example on how should read preference be set in a sharded replicaset, because after trying countless of options I did not manage to make it work.

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            arch1r3ct Andrius Virbi?ianskas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: