-
Type:
Bug
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 3.1.0
-
Component/s: Async, Connection Management
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When a MongoClient is closed using the close() operation, it does not immediately close the connection pool. There is also no way to listen for a completed close of the connection pool.
During restarts, this potentially means the new connection pool has trouble connecting, leading to "hanging" requests or connection errors. In our use case, this is especially prevalent during integration testing where we do a lot of start/stops on the system and connection pool in quick succession.
Please see the attached example for a test case that eventually fails. Note that when a wait is introduced between close() and the next iteration, overlapping connection pool problems go away.
The close() API should either be synchronized, or should provide a callback option that will indicate when the close has completed. This will allow to wait for a full close before restarting other resources.