Skip to content

fix(NODE-6589): background task does not prune idle connections when minPoolSize=0 #4569

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

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Jun 26, 2025

Description

What is changing?

ConnectionPools now run the background thread to prune idle connections even when minPoolSize = 0.

Is there new documentation needed for these changes?

What is the motivation for this change?

Release Highlight

Idle Connections are now pruned during periods of no activity when minPoolSize=0

A MongoClient configured with a maxIdleTimeMS and minPoolSize of 0 is advantageous for workloads that have sustained periods of little or no activity because it allows the connection pool to close connections that are unused during these periods of inactivity. However, due to a bug in the ConnectionPool implementation, idle / perished connections were not cleaned up unless minPoolSize was non-zero.

With the changes in this PR, the ConnectionPool now always cleans up idle connections, regardless of minPoolSize.

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

@baileympearson baileympearson force-pushed the NODE-6589-background-task-cleans-up-pool-size-0 branch from 0363220 to 1ac3000 Compare June 26, 2025 20:13
@baileympearson baileympearson marked this pull request as ready for review June 27, 2025 17:55
@baileympearson baileympearson requested a review from a team as a code owner June 27, 2025 17:55
@durran durran self-assigned this Jun 30, 2025
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jun 30, 2025
@durran durran merged commit 7cbb641 into mongodb:main Jul 1, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants