-
Notifications
You must be signed in to change notification settings - Fork 533
Fix RUBY-2558 :secondary_preferred read preference in 3.6+ sharded clusters performs primary read #2200
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
Conversation
407d360
to
66bd58d
Compare
…usters performs primary read
# In replica sets and sharded clusters, read preference is passed | ||
# to the server if one is specified by the application, and there | ||
# is no default. | ||
read && read.slave_ok? || false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question without knowing internal semantics, why does this require || false
to be included? Asking because A || false
will always evaluate to A
in boolean algebra, so I'm wondering about what Ruby does when read
evaluates to a false-ish value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The || false
converts nil to false (when read
is nil, in this case).
# If the read preference contains only mode and mode is secondary | ||
# preferred and we are sending to a pre-OP_MSG server, this read | ||
# preference is indicated by the :slave_ok wire protocol flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a moment to realise that the comment explains when the $readPreference
option doesn't need to be added. Maybe add another sentence like "In all other cases, add the $readPreference
option" might help clarify this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I added a note to this effect.
* master: Use frozen strings by default (mongodb#2202) RUBY-2561 Remove skipReason from estimatedDocumentCount test in versioned API (mongodb#2203)
No description provided.