<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:07 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-204] Concurrency Issue on failure recovery</title>
                <link>https://jira.mongodb.org/browse/CSHARP-204</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Note: using git revision 1a730b for line numbers.&lt;/p&gt;

&lt;p&gt;While doing high-concurrency load tests (~2000 connections) against our web service which calls mongo I ran into a concurrency issue that narrowed down to a problem between MongoServer.Disconnect() and MongoServer.AcquireConnection(MongoDatabase database,bool slaveOk). &lt;/p&gt;

&lt;p&gt;The issue occurs when an exception occurs within a MongoConnection between the GetConectionPoolEndPoint call (MongoServer.cs:798) and the connectionPool.AcquireConnection(database) (MongoServer.cs:807) call in AcquireConnection(database, endPoint) (MongoServer.cs:799).&lt;/p&gt;

&lt;p&gt;Since MongoConnection.HandleException() is forcing a server disconnect, when connectionPool.AcquireConnection(database) gets called, the result is eventually a InvalidOperationException(&quot;Attempt to get a connection from a closed connection pool&quot;) exception (MongoConnectionPool.cs:103).&lt;/p&gt;

&lt;p&gt;As this is a concurrency issue that I&apos;ve only seen in a very specific test, I have been unable to write a reliable test for it (we have to saturate the data link with several Gbps of data to make it fail semi-consistently).&lt;/p&gt;

&lt;p&gt;Attached is the patch that I&apos;ve implemented to fix this issue, since the lock() calls are reentrant we simply wrap both GetConectionPoolEndPoint and AcquireConnection with a lock(serverLock). So far this code has performed well, but it needs to be thoroughly reviewed to make sure my simple fix will not cause deadlocks on some scenario I have not taken into account.&lt;/p&gt;

&lt;p&gt;This bug possibly affects previous versions.&lt;/p&gt;</description>
                <environment>Windows 2003, IIS, connected to a single mongos instance</environment>
        <key id="16158">CSHARP-204</key>
            <summary>Concurrency Issue on failure recovery</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="mpilar">Miguel Pilar</reporter>
                        <labels>
                            <label>concurrency</label>
                    </labels>
                <created>Fri, 15 Apr 2011 17:10:39 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:43 +0000</updated>
                            <resolved>Mon, 6 Jun 2011 18:26:12 +0000</resolved>
                                    <version>1.0</version>
                                    <fixVersion>1.1</fixVersion>
                                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="36424" author="rstam" created="Mon, 6 Jun 2011 18:26:12 +0000"  >&lt;p&gt;Reviewed the patch and agreed with it. Thanks Miguel!&lt;/p&gt;</comment>
                            <comment id="33893" author="kamaradclimber" created="Mon, 23 May 2011 09:18:27 +0000"  >&lt;p&gt;This issue also occured on Linux with mongo 1.8.1  and the last stable c# driver.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="11696" name="AcquireConnection-Concurrency-problem-fix.patch" size="957" author="mpilar" created="Fri, 15 Apr 2011 17:10:39 +0000"/>
                    </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|hrh93b:</customfieldvalue>

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