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-4429): select server sync for endSessions during close #3363

Merged
merged 4 commits into from Aug 17, 2022

Conversation

durran
Copy link
Member

@durran durran commented Aug 16, 2022

Description

This prevents the endSessions command from going through server selection when no server would be selected after calling client.close(). This could happen in situations where the server has gone down but server selection keeps forcing monitor checks for up to serverSelectionTimeoutMS when an immediate return is desired.

What is changing?

  • MongoClient's close() method now does a quick server selection to get the list of servers that would be returned with a primary preferred read preference. If nothing is returned then calling endSessions is skipped.
Is there new documentation needed for these changes?

None

What is the motivation for this change?

NODE-4429

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

@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Aug 16, 2022
@nbbeeken nbbeeken self-requested a review August 16, 2022 21:06
src/mongo_client.ts Outdated Show resolved Hide resolved
nbbeeken
nbbeeken previously approved these changes Aug 16, 2022
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.

Small TS error I think but LGTM otherwise

@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 Aug 16, 2022
src/mongo_client.ts Show resolved Hide resolved
@nbbeeken nbbeeken changed the title fix(NODE-4429): short circuit end sessions during close fix(NODE-4429): select server sync for endSessions during close Aug 17, 2022
@nbbeeken nbbeeken merged commit 5086ead into main Aug 17, 2022
@nbbeeken nbbeeken deleted the NODE-4429 branch August 17, 2022 17:33
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
4 participants