-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Set read_preference to primaryPreferred when topology single with replica set. #266
Set read_preference to primaryPreferred when topology single with replica set. #266
Conversation
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.
Looks good to me. Please call mix credo
. Thank you!
lib/mongo/topology_description.ex
Outdated
|
||
:sharded -> | ||
{mongos_servers(topology), ReadPreference.to_mongos(read_preference)} | ||
{mongos_servers(topology) |> pick_server(), ReadPreference.to_mongos(read_preference)} |
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.
Did you execute mix credo
? It should complain about the |> operator.
topology |> mongos_servers() |> pick_server()
Looks nicer.
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.
Updated it. Thanks!
lib/mongo/topology_description.ex
Outdated
|
||
_other -> | ||
{select_replica_set_server(topology, read_preference.mode, read_preference), ReadPreference.to_replica_set(read_preference)} | ||
{select_replica_set_server(topology, read_preference.mode, read_preference) |> pick_server(), ReadPreference.to_replica_set(read_preference)} |
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.
topology |> select_replica_set_server(read_preference.mode, read_preference) |> pick_server()
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.
Updated it. Thanks!
…lica set. (zookzook#266) * Set read preference as primaryPreferred when topology is single and is replica. * Put missing replica? in ServerDescription.parse_hello_response/1 and add test. * update code format.
We found the issue with querying the data when we use
directConnection=true
and the cluster is a replica set. We got this error by using the following steps.Then I traced the Python MongoDB driver source code and found it set read_preference to
primaryPreferred
when topology single with replica set. Here is the reference.After the changes, the query will work.
Please review it. Thank you!