<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:53 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>[CSHARP-454] &quot;Deadlock&quot; in connection pool management</title>
                <link>https://jira.mongodb.org/browse/CSHARP-454</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Recently, we started getting occasional unexplainable &quot;hangs&quot; that coincided with hitting the connection pool upper limit. I spent some time debugging, but could not repeat the case on test machine, so I waited till one of our servers &quot;hanged&quot;, then dumped app server process and loaded it into WinDBG. &lt;br/&gt;
I&apos;ll spare you the details, but the culprit in our case lies in MongoServer.RequestStart method. The problem is that RequestStart locks on _serverLock, then proceeds to call MongoServerInstance.AcquireConnection, which, in it&apos;s turn, calls MongoConnectionPool.AcquireConnection. When you&apos;ve already hit the connection pool limit, MongoConnectionPool.AcquireConnection starts waiting on _connectionPoolLock with a timeout (wait queue). Too bad, the MongoServer.ReleaseConnection() locks on MongoServer._serverLock, so no connections can be released back, which leads to connection management being stalled for WaitQueueTimeout. &lt;br/&gt;
Other suspicious methods (that access connection pool to acquire connections) include MongoServer.VerifyState and MongoServer.ChooseServerInstance(due to it&apos;s call to MongoServer.VerifyUnknownState). Take not that while I think they may contain similar locking pattern, I&apos;m not exactly sure and not yet observed problems related to these two methods (although VerifyState certainly looks like it has the same problem).&lt;/p&gt;

&lt;p&gt;I would like to note that this is a very disrupting issue, because sooner or later it brings down any server that is approaching a certain load. The most obvious fix is increasing connection pool limit, and it appears to solve the issue, but it doesn&apos;t feel like a proper long-term solution.&lt;/p&gt;</description>
                <environment></environment>
        <key id="37182">CSHARP-454</key>
            <summary>&quot;Deadlock&quot; in connection pool management</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="9">Done</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="onyxmaster">Aristarkh Zagorodnikov</reporter>
                        <labels>
                            <label>c#</label>
                            <label>connections</label>
                            <label>deadlock</label>
                            <label>driver</label>
                    </labels>
                <created>Wed, 25 Apr 2012 19:09:46 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:41 +0000</updated>
                            <resolved>Thu, 26 Apr 2012 19:55:55 +0000</resolved>
                                    <version>1.4.1</version>
                                    <fixVersion>1.4.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="114267" author="onyxmaster" created="Fri, 27 Apr 2012 06:56:38 +0000"  >&lt;p&gt;Good to hear, waiting for 1.4.2 release =)&lt;/p&gt;</comment>
                            <comment id="114124" author="rstam" created="Thu, 26 Apr 2012 19:55:49 +0000"  >&lt;p&gt;This should be fixed now. Changes include:&lt;/p&gt;

&lt;p&gt;1. RequestStart/Done now release the lock before calling out to other methods&lt;br/&gt;
2. Ping and VerifyState now use a new connection instead of one from the connection pool&lt;/p&gt;

&lt;p&gt;Using a new connection for Ping and VerifyState prevents these methods from being stalled when the connection pool is oversubscribed. Opening and closing a connection for just this purpose is not too much overhead because it&apos;s only done every few seconds (every 10 seconds at the moment).&lt;/p&gt;

&lt;p&gt;There are also minor changes to MongoConnection reflecting the fact that we can now have a connection that is &lt;b&gt;not&lt;/b&gt; part of the connection pool.&lt;/p&gt;</comment>
                            <comment id="113970" author="rstam" created="Thu, 26 Apr 2012 12:07:31 +0000"  >&lt;p&gt;Thanks for reporting this. We&apos;re working on it.&lt;/p&gt;</comment>
                            <comment id="113913" author="onyxmaster" created="Thu, 26 Apr 2012 07:15:29 +0000"  >&lt;p&gt;Also, it appears that this problem was there for some time, it just became more visible since &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-408&quot; title=&quot;WaitQueueTimeout default value&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-408&quot;&gt;&lt;del&gt;CSHARP-408&lt;/del&gt;&lt;/a&gt; was implemented.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <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|hrh7mv:</customfieldvalue>

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