-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NODE-5981): read preference not applied to commands properly #4010
Merged
nbbeeken
merged 31 commits into
main
from
NODE-5981-fix-applying-read-preference-to-command
Mar 11, 2024
Merged
fix(NODE-5981): read preference not applied to commands properly #4010
nbbeeken
merged 31 commits into
main
from
NODE-5981-fix-applying-read-preference-to-command
Mar 11, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nbbeeken
changed the title
fix(NODE-5981): Implement 6.x: Read preference not applied to commands properly
fix(NODE-5981): read preference not applied to commands properly
Mar 1, 2024
nbbeeken
added
the
Primary Review
In Review with primary reviewer, not yet ready for team's eyes
label
Mar 6, 2024
This was referenced Jun 29, 2024
This was referenced Jul 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add
$readPrefernce
to commands according to spec.Topology type: Single
A deployment of topology type Single contains only a single server of any type. Topology type Single signifies a direct connection intended to receive all read and write operations.
Therefore, read preference is ignored during server selection with topology type Single. The single server is always suitable for reads if it is available. Depending on server type, the read preference is communicated to the server differently:
The single server is always suitable for write operations if it is available.
What is changing?
Implementation
prepareCommand()
, apply$readPrefernce
to commands according to specdirectConnection
option when we create a connection in the connection poolTests
test/integration/server-selection/readpreference.test.js
to TypeScriptreadPreference
tests (fixes NODE-5263)run-command
spec testsIs there new documentation needed for these changes?
None
What is the motivation for this change?
NODE-5981
Release Highlight
Fixed applying read preference to commands depending on topology
When connecting to a secondary in a replica set with a direct connection, if a read operation is performed, the driver attaches a read preference of
primaryPreferred
to the command.Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript