Skip to content

fix(NODE-6630): read all messages in buffer when chunk arrives #4512

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

Merged
merged 6 commits into from
Apr 18, 2025

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Apr 16, 2025

Description

What is changing?

  • Empty the current pool of chunks into the SizedMessageStream if more than one message can be read from it
Is there new documentation needed for these changes?

No

What is the motivation for this change?

Addresses an issue where streaming hellos would take approximately the maxAwaitTimeMS amount of time to push out the next update from the buffer.

Release Highlight

Fix processing of multiple messages within one network data chunk

During elections, or other scenarios where the server is pushing multiple topology updates to the driver in a short period of time, a bug in the driver's socket code led to backlog of topology updates that would remain in the buffer until another heartbeat arrived from the server. This could lead to delays in the driver recovering from an election and/or an increase in MongoServerSelectionErrors.

Now, all messages in the current buffer are returned to the driver leading to faster processing times.

Huge thank you to @andreim-brd for sharing a self-contained reproduction that proved to be instrumental in the identification of the underlying issue!

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
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken requested a review from a team as a code owner April 16, 2025 20:18
@nbbeeken nbbeeken force-pushed the NODE-6630-mon-slow branch 2 times, most recently from a3df4b1 to e37b6a9 Compare April 16, 2025 20:52
@nbbeeken nbbeeken requested a review from dariakp April 16, 2025 22:30
@nbbeeken nbbeeken force-pushed the NODE-6630-mon-slow branch from e37b6a9 to 40b7e18 Compare April 16, 2025 22:37
@baileympearson baileympearson self-assigned this Apr 17, 2025
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Apr 17, 2025
@baileympearson baileympearson added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Apr 17, 2025
@baileympearson baileympearson dismissed dariakp’s stale review April 17, 2025 19:25

re-requesting review

@baileympearson baileympearson merged commit 8c86e30 into main Apr 18, 2025
30 checks passed
@baileympearson baileympearson deleted the NODE-6630-mon-slow branch April 18, 2025 14:49
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