New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MongoDB ReadPreference configuration #156

Closed
jimlambie opened this Issue Dec 6, 2016 · 7 comments

Comments

Projects
2 participants
@jimlambie
Copy link
Member

jimlambie commented Dec 6, 2016

API needs a way to configure the ReadPreference when connecting to a replica set, as per this page in the docs: https://docs.mongodb.com/v3.0/core/read-preference/

@jimlambie jimlambie added this to the 1.15.0 milestone Dec 21, 2016

@jimlambie

This comment has been minimized.

Copy link
Member Author

jimlambie commented Jan 12, 2017

@fra967 can you please confirm this covers what you require for readPreference?

https://docs.mongodb.com/manual/reference/read-preference/

@fra967

This comment has been minimized.

Copy link
Member

fra967 commented Jan 12, 2017

We will probably want to set it to secondaryPreferred in order to fall back to the primary.
I believe we also need to issue a rs.slaveOk() before sending the query (at least, that's what needs to be done from the shell, not sure if the drive would do that automatically)

@jimlambie

This comment has been minimized.

Copy link
Member Author

jimlambie commented Jan 20, 2017

@fra967 I believe that happens internally, as seen by this getter on the Db class:

// slaveOk specified
Object.defineProperty(Db.prototype, 'slaveOk', {
  enumerable:true,
  get: function() {
    if(this.s.options.readPreference != null
      && (this.s.options.readPreference != 'primary' || this.s.options.readPreference.mode != 'primary')) {
      return true;
    }
    return false;
  }
});
@fra967

This comment has been minimized.

Copy link
Member

fra967 commented Jan 20, 2017

cool, so I guess we just need to test it :)

@jimlambie

This comment has been minimized.

Copy link
Member Author

jimlambie commented Jan 23, 2017

@fra967 do you have a preference for the default setting? or should secondaryPreferred be default?

@fra967

This comment has been minimized.

Copy link
Member

fra967 commented Jan 26, 2017

yes @jimlambie please let's use secondaryPreferred as default value

@jimlambie jimlambie removed this from the 1.15.0 milestone Jan 30, 2017

@jimlambie

This comment has been minimized.

Copy link
Member Author

jimlambie commented Jan 30, 2017

Rolled into #171

jimlambie added a commit that referenced this issue Feb 3, 2017

feat: add readPreference configuration option
Default to “secondaryPreferred”

Close #156

@jimlambie jimlambie self-assigned this Feb 3, 2017

@jimlambie jimlambie added this to In Progress in API Version 2 Feb 14, 2017

jimlambie added a commit that referenced this issue Apr 27, 2017

feat: add readPreference configuration option
Default to “secondaryPreferred”

Close #156

@jimlambie jimlambie closed this in db8a82f May 29, 2017

@jimlambie jimlambie removed the in progress label May 29, 2017

@jimlambie jimlambie moved this from In Progress to Review in API Version 2 May 29, 2017

@jimlambie jimlambie removed this from In progress in API Roadmap May 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment