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

ReplicaSetStatus does not interrupt the Updater thread on close

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.6.3
    • Fix Version/s: 2.8.0
    • Component/s: Cluster Management
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • # Replies:
      3
    • Last comment by Customer:
      false

      Description

      com.mongodb.ReplicaSetStatus.Updater thread should be interrupted and closed gracefully upon Mongo.close() call. I know it's a daemon thread, but in Tomcat, when redeploying I get:

      SEVERE: The web application [/ssp] appears to have started a thread named [ReplicaSetStatus:Updater] but has failed to stop it. This is very likely to create a memory leak.

      Also see: JAVA-191

        Issue Links

          Activity

          Hide
          markustripp Markus Tripp added a comment - - edited

          When you execute Mongo.close() this triggers ReplicaSetStatus.close() which updates the _close variable.

          Unfortunately the ReplicaSetStatus Updater Thread sleeps for up to 5 sec. until it checks the _close variable again. In this time Tomcat already undeployed and deployed the application and detected the potential memory leak problems. You can easily verify this if you close Mongo and sleep for > 5 sec. in the destroy method of your Servlet. Then you won't experience the problem. But this is not a good workaround.

          Better would be if the ReplicaSetStatus.close method interrupts the sleeping Thread so that it immediately closes safely. The problem is that the Tomcat classloader cannot cleanup correctly which results in a growth of the PermGen memory region, which in the end can result in an OutOfMemoryError.

          Show
          markustripp Markus Tripp added a comment - - edited When you execute Mongo.close() this triggers ReplicaSetStatus.close() which updates the _close variable. Unfortunately the ReplicaSetStatus Updater Thread sleeps for up to 5 sec. until it checks the _close variable again. In this time Tomcat already undeployed and deployed the application and detected the potential memory leak problems. You can easily verify this if you close Mongo and sleep for > 5 sec. in the destroy method of your Servlet. Then you won't experience the problem. But this is not a good workaround. Better would be if the ReplicaSetStatus.close method interrupts the sleeping Thread so that it immediately closes safely. The problem is that the Tomcat classloader cannot cleanup correctly which results in a growth of the PermGen memory region, which in the end can result in an OutOfMemoryError.
          Hide
          jeff.yemin Jeff Yemin added a comment -

          I fixed this in the context of JAVA-458

          Show
          jeff.yemin Jeff Yemin added a comment - I fixed this in the context of JAVA-458
          Hide
          jeff.yemin Jeff Yemin added a comment -

          Closing for 2.8.0 release.

          Show
          jeff.yemin Jeff Yemin added a comment - Closing for 2.8.0 release.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 11 weeks, 4 days ago
                Date of 1st Reply: