Skip to content
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-3648): run get more ops through server selection #3030

Merged
merged 12 commits into from
Nov 18, 2021
Merged

Conversation

durran
Copy link
Member

@durran durran commented Nov 8, 2021

Description

Runs getmore command operations through server selection, selecting the same server.

What is changing?

A new server selector has been added, sameServerSelector, which takes a ServerDescription and returns a ServerDescription[]. This will always select the same server as the description provided, unless the server has transitioned into an unknown state, where it will return an empty array. In this case, server selection will force monitor checks to potentially update the server and select the same one again.

A new GetMoreOperation has been added in order for the cursors on getMore to execute this operation with server selection. The pinned server's description on the operation will be used in conjunction with the new server selector.

Is there new documentation needed for these changes?

No

What is the motivation for this change?

NODE-3648
NODE-3453
HELP-28682

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@durran durran added the wip label Nov 8, 2021
src/operations/execute_operation.ts Show resolved Hide resolved
src/operations/get_more.ts Outdated Show resolved Hide resolved
src/sdam/server_selection.ts Show resolved Hide resolved
test/unit/operations/get_more.test.js Show resolved Hide resolved
test/unit/sdam/server_selection.test.js Show resolved Hide resolved
test/unit/sdam/server_selection.test.js Show resolved Hide resolved
@durran durran force-pushed the NODE-3648 branch 2 times, most recently from 66941be to a95b0fd Compare November 8, 2021 15:53
@durran durran added Primary Review In Review with primary reviewer, not yet ready for team's eyes and removed wip labels Nov 8, 2021
@nbbeeken nbbeeken self-requested a review November 8, 2021 22:30
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

Some initial thoughts. This is very close to ready as is, but there's another component to fixing the original bug that we could consider to include here. Only in this version of the driver have we now dropped support for versions of MongoDB that don't support sessions. Part of the issue was that our hasSessionSupport logic was omitting the session because the monitors downgraded it. Now that we run getMores through serverSelection we shouldn't encounter this issue.

But should additionally remove the checks altogether? and in fact maybe we should consider throwing Connection#getMore if we don't have a session at that point. (possibly too far) but IIUC of all operations getMores 100% need to have a session defined. (with our currently supported server vers)

src/operations/execute_operation.ts Show resolved Hide resolved
src/sdam/server_selection.ts Outdated Show resolved Hide resolved
src/operations/get_more.ts Outdated Show resolved Hide resolved
src/operations/get_more.ts Show resolved Hide resolved
@durran durran requested a review from nbbeeken November 17, 2021 16:20
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

LGTM

src/operations/execute_operation.ts Show resolved Hide resolved
@nbbeeken nbbeeken added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Nov 17, 2021
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

Just a few small suggestions around the testing

test/unit/sdam/server_selection.test.js Outdated Show resolved Hide resolved
test/unit/sdam/server_selection.test.js Outdated Show resolved Hide resolved
test/unit/sdam/server_selection.test.js Show resolved Hide resolved
describe('GetMoreOperation', function () {
const ns = 'db.coll';
const cursorId = Long.fromNumber(1);
const options = {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we freeze these so that we can make sure the options aren't mutated? (otherwise that deep equal check below doesn't guarantee as much)

Copy link
Member Author

Choose a reason for hiding this comment

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

Now all params are frozen.

@durran durran requested a review from dariakp November 18, 2021 09:20
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

One small nit

test/unit/operations/get_more.test.js Outdated Show resolved Hide resolved
Co-authored-by: Daria Pardue <[email protected]>
@dariakp dariakp merged commit 268e211 into main Nov 18, 2021
@dariakp dariakp deleted the NODE-3648 branch November 18, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants