<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:24 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-294] Deadlock when connecting to a replica set</title>
                <link>https://jira.mongodb.org/browse/CSHARP-294</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Initial connection to a replica set leads to deadlock. The source of the deadlock is the change of the locking protocol in response to the &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-268&quot; title=&quot;NullReferenceException on lost primary&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-268&quot;&gt;&lt;del&gt;CSHARP-268&lt;/del&gt;&lt;/a&gt;.&lt;br/&gt;
While connecting to a replica set of 3 machines (primary, secondary, arbiter) first time, a deadlock occurs with the following four threads of interest:&lt;br/&gt;
1. actual connection thread:&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.Internal.BlockingQueue&amp;lt;System.__Canon&amp;gt;.Dequeue(System.TimeSpan timeout) Line 53	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.Internal.ReplicaSetConnector.Connect(System.TimeSpan timeout) Line 61 + 0xc bytes	C#&lt;br/&gt;
	MongoDB.Driver.dll!MongoDB.Driver.MongoServer.Connect(System.TimeSpan timeout) Line 457	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoServer.GetServerInstance(bool slaveOk) Line 976 + 0xd bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoServer.AcquireConnection(MongoDB.Driver.MongoDatabase database, bool slaveOk) Line 920	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoCursorEnumerator&amp;lt;System.__Canon&amp;gt;.AcquireConnection() Line 184 + 0x42 bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoCursorEnumerator&amp;lt;MongoDB.Bson.BsonDocument&amp;gt;.GetFirst() Line 194 + 0xc bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoCursorEnumerator&amp;lt;System.__Canon&amp;gt;.MoveNext() Line 126 + 0x8 bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoDatabase.GetCollectionNames() Line 649 + 0xdc bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoDatabase.CollectionExists(string collectionName) Line 290 + 0xa bytes	C#&lt;/p&gt;

&lt;p&gt;2,3,4: instance connection threads:&lt;br/&gt;
 	&lt;span class=&quot;error&quot;&gt;&amp;#91;In a sleep, wait, or join&amp;#93;&lt;/span&gt;	&lt;br/&gt;
	MongoDB.Driver.dll!MongoDB.Driver.MongoServer.InstanceStateChanged(object sender, object args) Line 1037	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoServerInstance.State.set(MongoDB.Driver.MongoServerState value) Line 174 + 0xd bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.MongoServerInstance.Connect(bool slaveOk) Line 216 + 0x11 bytes	C#&lt;br/&gt;
 	MongoDB.Driver.dll!MongoDB.Driver.Internal.ReplicaSetConnector.ConnectWorkItem(object argsObject) Line 100 + 0xd bytes	C#&lt;br/&gt;
 	mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x178 bytes	&lt;br/&gt;
 	&lt;span class=&quot;error&quot;&gt;&amp;#91;Native to Managed Transition&amp;#93;&lt;/span&gt;	&lt;br/&gt;
 	&lt;span class=&quot;error&quot;&gt;&amp;#91;Managed to Native Transition&amp;#93;&lt;/span&gt;	&lt;br/&gt;
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xa1 bytes	&lt;br/&gt;
 	mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x69 bytes	&lt;br/&gt;
 	mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x193 bytes	&lt;br/&gt;
 	mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x35 bytes	&lt;/p&gt;

&lt;p&gt;Both kinds of threads have the lock on serverLock (MongoServer.Connect for 1st kind and MongoServer.InstanceStateChanged for 2nd kind) and the first thread appears to wait second ones to connect, which they can&apos;t do, because they&apos;re blocked on the lock.&lt;/p&gt;</description>
                <environment></environment>
        <key id="20346">CSHARP-294</key>
            <summary>Deadlock when connecting to a replica set</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>
                    </labels>
                <created>Mon, 1 Aug 2011 11:53:14 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:36 +0000</updated>
                            <resolved>Fri, 5 Aug 2011 21:14:50 +0000</resolved>
                                    <version>1.2</version>
                                    <fixVersion>1.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="46720" author="rstam" created="Fri, 5 Aug 2011 21:14:50 +0000"  >&lt;p&gt;The changes to fix &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-268&quot; title=&quot;NullReferenceException on lost primary&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-268&quot;&gt;&lt;del&gt;CSHARP-268&lt;/del&gt;&lt;/a&gt; also fixed this issue.&lt;/p&gt;</comment>
                            <comment id="46718" author="rstam" created="Fri, 5 Aug 2011 21:14:33 +0000"  >&lt;p&gt;The changes made to fix &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-268&quot; title=&quot;NullReferenceException on lost primary&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-268&quot;&gt;&lt;del&gt;CSHARP-268&lt;/del&gt;&lt;/a&gt; also fixed this issue.&lt;/p&gt;</comment>
                            <comment id="45827" author="onyxmaster" created="Tue, 2 Aug 2011 10:10:36 +0000"  >&lt;p&gt;Since the deadlock fixes and followup are in &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-268&quot; title=&quot;NullReferenceException on lost primary&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-268&quot;&gt;&lt;del&gt;CSHARP-268&lt;/del&gt;&lt;/a&gt;, maybe this case should be closed as duplicate or merged with &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-268&quot; title=&quot;NullReferenceException on lost primary&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-268&quot;&gt;&lt;del&gt;CSHARP-268&lt;/del&gt;&lt;/a&gt;?&lt;/p&gt;</comment>
                            <comment id="45546" author="onyxmaster" created="Mon, 1 Aug 2011 11:58:10 +0000"  >&lt;p&gt;Forgot to add that while deadlock isn&apos;t indefinite, it leads to &quot;Unable to connect to server.&quot; error on first connection after it times out.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="19455">CSHARP-268</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|hrh8kn:</customfieldvalue>

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