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

Netty Event Loop Resource Leak on synchronous MongoClient Close

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.4.1
    • Affects Version/s: 5.0.0
    • Component/s: None
    • None
    • None
    • Java Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      When creating a MongoClient with NettyTransportSettings where the eventLoopGroup is created by default in the driver, closing the client does not properly shut down the event loop threads, causing the application to hang.

      Steps to Reproduce:

      //Create a MongoClient using NettyTransportSettings:
      MongoClient mongoClient = MongoClients.create(MongoClientSettings.builder() .transportSettings(TransportSettings.nettyBuilder().build()) .build());
      
      //Perfrorm any IO operation
      mongoClient.getDatabase("test").getCollection("test").find().forEach(System.out::println);
      
      //Close the client
      mongoClient.close();

      Expected Behavior:

      • The synchronous/legacy MongoClient.close() call should shut down any event loop threads created by the driver when the eventLoopGroup was not explicitly provided.

      Actual Behavior:

      • The application hangs because the event loop threads remain active after closing the client.

            Assignee:
            slav.babanin@mongodb.com Slav Babanin
            Reporter:
            slav.babanin@mongodb.com Slav Babanin
            Maxim Katcharov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: