Skip to content

PYTHON-1864 PYTHON-2931 Spec complaint $readPreference #809

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

Merged
merged 6 commits into from
Dec 13, 2021

Conversation

ShaneHarvey
Copy link
Member

This change fixes how pymongo sends $readPreference to the server via OP_MSG:

  • Stop sending $readPreference to standalone servers. The spec says to omit it.
  • Stop sending $readPreference with primary read preference to all servers. The spec says to omit "primary" since it's the server's default.
  • The final rule is to always send $readPreference=primaryPreferred when directly connected to a single replica set member. This is to ensure that the app does not get NotPrimary errors for direct connections.

This change also removes the secondary_ok variable which is no longer needed. Instead of tracking the "secondary ok" boolean we replace the input read preference with the effective read preference (primary, primaryPreferred, or the original read preference).

This change depends on #774 so please review that one first.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ShaneHarvey
Copy link
Member Author

Update to fix the merge conflicts. @juliusgeo please take a look.

Copy link
Contributor

@juliusgeo juliusgeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ShaneHarvey ShaneHarvey merged commit ff3a8b4 into mongodb:master Dec 13, 2021
juliusgeo pushed a commit to juliusgeo/mongo-python-driver that referenced this pull request Apr 5, 2022
Stop sending $readPreference to standalone servers.
Stop sending $readPreference primary because it's the server default.
Remove outdated secondary_ok flag.
juliusgeo pushed a commit to juliusgeo/mongo-python-driver that referenced this pull request Apr 7, 2022
Stop sending $readPreference to standalone servers.
Stop sending $readPreference primary because it's the server default.
Remove outdated secondary_ok flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants