<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:31 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-333] 1.2 Crashes our App Domain with a Exception: System.TimeoutException: Timeout waiting for a MongoConnection</title>
                <link>https://jira.mongodb.org/browse/CSHARP-333</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;We experienced exactly the same symptoms as &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-323&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/CSHARP-323&lt;/a&gt; last night when deploying to our live servers on AWS. Subsequently I tried going to the latest build of 1.3, with the same result. I reverted back to 1.1, and we are trying to replicate the issue locally. I will post more info when I managed to do this. &lt;/p&gt;</description>
                <environment>Win 2008 R2 servers connecting to 3-node ubuntu RS on AWS</environment>
        <key id="22992">CSHARP-333</key>
            <summary>1.2 Crashes our App Domain with a Exception: System.TimeoutException: Timeout waiting for a MongoConnection</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="kenny.inggs">Kenny Inggs</reporter>
                        <labels>
                    </labels>
                <created>Thu, 29 Sep 2011 07:47:47 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:45 +0000</updated>
                            <resolved>Thu, 6 Oct 2011 03:40:47 +0000</resolved>
                                    <version>1.2</version>
                                    <fixVersion>1.3</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="95536" author="rstam" created="Mon, 5 Mar 2012 21:39:45 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-406&quot; title=&quot;Deadlock and TimeoutException when acquiring connection.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-406&quot;&gt;&lt;del&gt;CSHARP-406&lt;/del&gt;&lt;/a&gt; fixes the most likely cause for seeing this exception. Note that under heavy loads you might still see this exception.&lt;/p&gt;</comment>
                            <comment id="59063" author="kenny.inggs" created="Fri, 7 Oct 2011 11:37:12 +0000"  >&lt;p&gt;A huge thanks for your help Robert and Aaron. I can confirm that this was our problem as well. I just couldn&apos;t replicate it, even with days of testing, since the only place we accidentally called Disconnect was in a &apos;Healthcheck&apos; page that we only use for our load-balancer on our live environment, so our test environment never fell over. &lt;/p&gt;</comment>
                            <comment id="58882" author="rstam" created="Thu, 6 Oct 2011 19:29:25 +0000"  >&lt;p&gt;When an error occurs on a connection that connection is closed and removed the pool. A new connection will be created as needed eventually to replace it.&lt;/p&gt;</comment>
                            <comment id="58874" author="aaron@tapconsulting.com" created="Thu, 6 Oct 2011 19:18:48 +0000"  >&lt;p&gt;removed server.Disconnect() and now no problems and runs much faster too (which makes sense).  &lt;/p&gt;

&lt;p&gt;Interested to hear how the connection pooling works, like how does it prevent all of the available connections from being used up when exceptions occur?&lt;/p&gt;</comment>
                            <comment id="58829" author="rstam" created="Thu, 6 Oct 2011 17:53:20 +0000"  >&lt;p&gt;I hadn&apos;t realized that the documentation at:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;didn&apos;t really discuss when it is appropriate to call Connect or Disconnect. I will add some documentation on that.&lt;/p&gt;

&lt;p&gt;Because we use connection pooling connections are not normally closed when a database operation completes. Instead the connection just goes back to the connection pool to be used again later.&lt;/p&gt;

&lt;p&gt;Connection pooling is all automatic. There is nothing you have to do (unless you are using RequestStart, and then you either have to use the using statement or make sure to call RequestDone to return the reserved connection to the connection pool).&lt;/p&gt;</comment>
                            <comment id="58820" author="aaron@tapconsulting.com" created="Thu, 6 Oct 2011 17:06:58 +0000"  >&lt;p&gt;So, I thought I was supposed to be calling disconnect so that I would not run out of connections. Is it safe to assume when the connection goes out of scope it will be disconnected safely?&lt;/p&gt;

&lt;p&gt;Can you point me to the documentation for the guidance on this so I can understand it a little better.&lt;/p&gt;

&lt;p&gt;Glad to help, least I can do since I love all the work you and the rest of the mongoDB team is doing.&lt;/p&gt;</comment>
                            <comment id="58755" author="rstam" created="Thu, 6 Oct 2011 03:37:59 +0000"  >&lt;p&gt;While I don&apos;t recommend you call Disconnect after every database operation, it should not have resulted in an error.&lt;/p&gt;

&lt;p&gt;There is a bug in Disconnect that causes the count of connections in the connection pool to get out of sync. After you call Disconnect enough times the connection pool thinks it is full when in fact it is empty (because the poolSize value is messed up). The result is the exception you are seeing.&lt;/p&gt;

&lt;p&gt;So even though you shouldn&apos;t be calling Disconnect, I&apos;m glad you did because it helped to discover this bug.&lt;/p&gt;

&lt;p&gt;Thanks a bunch for the code to reproduce this. It made working on this really easy. I really appreciate the effort you put into submitting an easily reproducible case.&lt;/p&gt;</comment>
                            <comment id="58742" author="rstam" created="Thu, 6 Oct 2011 01:23:54 +0000"  >&lt;p&gt;You shouldn&apos;t be calling Disconnect. Can you remove the calls to Disconnect and try again?&lt;/p&gt;</comment>
                            <comment id="58709" author="aaron@tapconsulting.com" created="Wed, 5 Oct 2011 22:19:56 +0000"  >&lt;p&gt;Visual studio 2010 console project attached.&lt;/p&gt;

&lt;p&gt;Ran this twice with the same results I&apos;m getting on the website.  After about ~100 connections it dies with the error&lt;/p&gt;</comment>
                            <comment id="58696" author="rstam" created="Wed, 5 Oct 2011 21:14:47 +0000"  >&lt;p&gt;If you are not setting the slaveOk value anywhere then the default will be false. SlaveOk is a client side setting in the driver.&lt;/p&gt;

&lt;p&gt;Is it possible to attach a console application that reproduces this?&lt;/p&gt;</comment>
                            <comment id="58694" author="aaron@tapconsulting.com" created="Wed, 5 Oct 2011 21:05:12 +0000"  >&lt;p&gt;1. It happens after 20+ requests/connections have been made from a given application.  The server is standalone (so no primary/slave).  I&apos;ve watched the server&apos;s process and logs and there is nothing there that looks suspicious.&lt;/p&gt;

&lt;p&gt;2. Where do I check for that?  I&apos;m not setting slaveOk explicitly anywhere in my code.  Is it a server or driver setting? &lt;/p&gt;

&lt;p&gt;I upgraded the server to 2.0 and continued getting the same issues.  I just reverted c# driver to 1.1 (which has been working for months) and do not have the same issue.&lt;/p&gt;</comment>
                            <comment id="58691" author="rstam" created="Wed, 5 Oct 2011 20:54:04 +0000"  >&lt;p&gt;@Aaron: a few questions:&lt;/p&gt;

&lt;p&gt;1. Did this occur after the system had been running normally for some time, or when the very first request was made of the database? If after awhile, did anything else happen at that time (a server went offline, a new primary was elected, etc...)?&lt;/p&gt;

&lt;p&gt;2. What was the value of slaveOk?&lt;/p&gt;</comment>
                            <comment id="58688" author="aaron@tapconsulting.com" created="Wed, 5 Oct 2011 20:48:23 +0000"  >&lt;p&gt;I&apos;m getting something very similar with the 1.2 driver.  Once I get the connection timeout I continue to get it for my client app until I restart it, but I can continue querying the database from other apps without problems.  Below is my stack trace:&lt;/p&gt;

&lt;p&gt;aaron@tapconsulting.com&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;MongoConnectionException: Unable to connect to server x.x.x.x:27017: Timeout waiting for a MongoConnection..&amp;#93;&lt;/span&gt;&lt;br/&gt;
   MongoDB.Driver.Internal.DirectConnector.Connect(TimeSpan timeout) +777&lt;br/&gt;
   MongoDB.Driver.MongoServer.Connect(TimeSpan timeout, ConnectWaitFor waitFor) +301&lt;br/&gt;
   MongoDB.Driver.MongoServer.Connect(ConnectWaitFor waitFor) +78&lt;br/&gt;
   MongoDB.Driver.MongoServer.ChooseServerInstance(Boolean slaveOk) +1008&lt;br/&gt;
   MongoDB.Driver.MongoServer.AcquireConnection(MongoDatabase database, Boolean slaveOk) +365&lt;br/&gt;
   MongoDB.Driver.MongoCursorEnumerator`1.AcquireConnection() +131&lt;br/&gt;
   MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() +91&lt;br/&gt;
   MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() +276&lt;br/&gt;
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +4216356&lt;br/&gt;
   MongoDB.Driver.MongoCollection.FindOneAs(IMongoQuery query) +167&lt;br/&gt;
   TC.Services.MongoDB.MongoSession.Single(Int32 id) +383&lt;/p&gt;</comment>
                            <comment id="57562" author="rstam" created="Thu, 29 Sep 2011 14:11:47 +0000"  >&lt;p&gt;Thanks. I&apos;ll keep an eye out for it.&lt;/p&gt;</comment>
                            <comment id="57559" author="kenny.inggs" created="Thu, 29 Sep 2011 14:02:41 +0000"  >&lt;p&gt;I will add a stack trace as soon as I replicate it in our test environment which should be early tomorrow morning. The server was inactive at the time (right after the deployment), so I wouldn&apos;t expect a &apos;normal&apos; Timeout. Will keep you posted. &lt;/p&gt;</comment>
                            <comment id="57556" author="rstam" created="Thu, 29 Sep 2011 13:43:29 +0000"  >&lt;p&gt;Can you provide a stack trace to either determine that it really is the same issue as &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-323&quot; title=&quot;Timeout in background state management thread crashes application domain&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-323&quot;&gt;&lt;del&gt;CSHARP-323&lt;/del&gt;&lt;/a&gt;, or if not, to determine exactly where the problem might be.&lt;/p&gt;

&lt;p&gt;A &quot;Timeout waiting for a MongoConnection&quot; can sometimes just mean that your server is overloaded and not responding quickly enough. Or if the load is very high you might just need configuration changes to increase the size of the connection pool and/or the timeout value for waiting for a connection.&lt;/p&gt;</comment>
                            <comment id="57518" author="kenny.inggs" created="Thu, 29 Sep 2011 07:49:01 +0000"  >&lt;p&gt;I missed something - We got the issue as we deployed version 1.2 of the driver (upgraded from 1.1) &lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="32116">CSHARP-406</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="13412" name="Mongo1.2DriverTest.zip" size="36372" author="aaron@tapconsulting.com" created="Wed, 5 Oct 2011 22:19:56 +0000"/>
                    </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|hrh8c7:</customfieldvalue>

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