[JAVA-2014] Async driver MongoClient.close() is not synchronous and has no callback Created: 13/Oct/15 Updated: 20/Oct/16 Resolved: 20/Oct/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Async, Connection Management |
| Affects Version/s: | 3.1.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Peter Hendriks | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
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. |
| Comments |
| Comment by Jeffrey Yemin [ 20/Oct/16 ] | ||||||||||||||||
|
MongoClient.close() ) does synchronously close the connection pool. The issue is lower than the driver, which is demonstrated with the following simple program:
Eventually this program will start throwing similar exceptions to what you observed with MongoClient. I don't think there's anything the driver can do to fix this. |