Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2014

Async driver MongoClient.close() is not synchronous and has no callback

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.1.0
    • 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            peterhendriks Peter Hendriks
            None
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: