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-3263): force closing a pool closes active connections #2804

Closed

Conversation

rose-m
Copy link
Contributor

@rose-m rose-m commented May 11, 2021

Prior to this PR using MongoClient.close(true) to force-close the client did also trigger a force-close of the connection pool and the individual connections. However, as the pool only tracked available connections (not all connections that were created by the pool), it could not close connections that were active.

This fix PR adds:

  • Tracking all connections that are created by the pool in a new internal Set.
  • On force-close instead of iterating only over the available connections it will iterate over all known connections and force-close them.
  • A test case is provided to ensure that also checked-out connections are force-closed.

The behavior and semantics of the MongoClient.close() (i.e. without force = true) remain unchanged.

The test case will fail when the iteration in line 342 is made only over the available connections.

@dariakp dariakp changed the title fix: force closing a pool closes active connections NODE-3263 fix(NODE-3263): force closing a pool closes active connections May 26, 2021
@dariakp dariakp marked this pull request as draft May 26, 2021 14:45
@dariakp
Copy link
Contributor

dariakp commented May 26, 2021

Converting this PR to draft pending additional investigation of NODE-3263

@dariakp dariakp added the tracked-in-jira Ticket filed in MongoDB's Jira system label May 26, 2021
@nbbeeken nbbeeken closed this Sep 27, 2021
@Xunnamius
Copy link

Just got bitten by this in my CLI app. I can't do a clean exit even after all operations have completed and after calling MongoClient.close(true); my program hangs unless I add a process.exit(0) at the end, which makes unit and integration testing a bit harder. Any plans on merging this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracked-in-jira Ticket filed in MongoDB's Jira system
Projects
None yet
4 participants