<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:54:12 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-1271] Java driver does not clean up thread resources (sometimes)</title>
                <link>https://jira.mongodb.org/browse/JAVA-1271</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;In the case of a RuntimeException such as a ClassNotFoundException, the Java driver may not clean up all of its resources, in particular the non-daemon threads used for pool eviction (the PooledConnectionProvider.sizeMaintenanceTimer).  This can cause web containers such as Tomcat to fail to shut down properly.  The scenario is as follows:&lt;/p&gt;

&lt;p&gt;1.  Deploy a web application which deploys a MongoClient connected to a 3 node replica set.&lt;br/&gt;
2.  Access the application&lt;br/&gt;
3.  Undeploy the application in Tomcat&lt;/p&gt;

&lt;p&gt;Even though MongoClient.close is called by the application, some threads will remain.  Any replica set polling threads other than the primary along with threads for maintaining the pools.  What happens here is the following:&lt;/p&gt;

&lt;p&gt;1.  MongoClient.close() is called&lt;br/&gt;
2.  ...&lt;br/&gt;
3.  ConcurrentPool.close() is called&lt;br/&gt;
4.  In closing the pool tries to instantiate a CLDIterator.  Since the jar containing the class has been removed a ClassNotFoundException is raised which fails termination of remaining threads.&lt;/p&gt;

&lt;p&gt;The PooledConnectionProvider should ensure that all threads created are shut down regardless of failures in the pool.close method.  Likewise the other close methods should insulate themselves from such failures.  Also, the threads Timer threads spawned for pool eviction should probably be set as daemon threads to avoid shutdown issues.&lt;/p&gt;</description>
                <environment>Tomcat 7.0.27</environment>
        <key id="141471">JAVA-1271</key>
            <summary>Java driver does not clean up thread resources (sometimes)</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="2">Won&apos;t Fix</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="clecompte">Chris LeCompte</reporter>
                        <labels>
                    </labels>
                <created>Wed, 11 Jun 2014 05:06:11 +0000</created>
                <updated>Wed, 19 Oct 2016 15:26:09 +0000</updated>
                            <resolved>Wed, 19 Oct 2016 15:26:09 +0000</resolved>
                                    <version>2.12.0</version>
                                                    <component>Error Handling</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="1412652" author="jeff.yemin" created="Wed, 19 Oct 2016 15:25:59 +0000"  >&lt;p&gt;I don&apos;t see a way to fix this in the general case, as a ClassNofFoundException could potentially be thrown at any level, even before we get to the PooledConnectionProvider.close() method.  So insulating that method against failure doesn&apos;t guarantee that it will get called in the first place.&lt;/p&gt;

&lt;p&gt;Since a Tomcat upgrade has mitigated the issue for you, and as no one else has reported this, I&apos;m going to close as Won&apos;t Fix.  If it comes up for other users we can re-open it.&lt;/p&gt;</comment>
                            <comment id="619038" author="clecompte@apple.com" created="Thu, 12 Jun 2014 18:21:51 +0000"  >&lt;p&gt;The application is calling MongoClient.close() as part of a destroy method of a singleton bean in a spring context.  The problem wasn&apos;t that classes were being unloaded but not loaded in the first place and since the file handle has been removed (the original webapp deleted) the loading of the class fails.  There is no stack trace since the exception is swallowed up by:&lt;/p&gt;

&lt;p&gt;        try &lt;/p&gt;
{
            _connector.close();
        }
&lt;p&gt; catch (final Throwable t) &lt;/p&gt;
{ /* nada */ }

&lt;p&gt;in Mongo.close().  An upgrade of tomcat seems to have mitigated although presumably it could still surface in other albeit rare cases.  It would probably make more sense to shut down the maintenance timer before closing the pool as well since there&apos;s a bit of a race condition between shutting down the pool completely and the running of the maintenance task.&lt;/p&gt;</comment>
                            <comment id="618061" author="jeff.yemin" created="Thu, 12 Jun 2014 02:59:35 +0000"  >&lt;p&gt;It&apos;s not clear to me why Tomcat starts unloading classes before MongoClient.close() completes.  Where is the application calling MongoClient.close() from?  Do you have a stack trace?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrzm0v:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>122078</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>