<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:38:54 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-1180] The wait queue for acquiring a connection to server is full</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1180</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I wanted to try the new 2.0 async features and used the C# Driver Tutorial with the following snippet:&lt;/p&gt;

&lt;p&gt;  Parallel.For(0, 100000, async _ =&amp;gt;&lt;br/&gt;
            {&lt;br/&gt;
                var e = new Entity &lt;/p&gt;
{ Name = &quot;Tom&quot; }
&lt;p&gt;;&lt;br/&gt;
                await collection.InsertOneAsync(e);&lt;br/&gt;
            });&lt;/p&gt;

&lt;p&gt;But after a short period my program fails:&lt;/p&gt;

&lt;p&gt;Unhandled Exception:&lt;br/&gt;
Unhandled Exception:&lt;br/&gt;
Unhandled Exception: MongoDB.Driver.MongoWaitQueueFullException: The wait queue&lt;br/&gt;
for acquiring a connection to server localhost:27017 is full.&lt;br/&gt;
   at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.&amp;lt;AcquireConnec&lt;br/&gt;
tionAsync&amp;gt;d__0.MoveNext()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location where exception was thrown &amp;#8212;&lt;/p&gt;

&lt;p&gt;When I change the connectionstring to: &quot;mongodb://localhost?maxpoolsize=20000 it seems to work, but hogs alot of memory (&amp;gt; 1GB Ram).&lt;/p&gt;

&lt;p&gt;Btw. 1.1.0 works totally fine.&lt;/p&gt;</description>
                <environment>Win 8.1 x64, MongoDB 2.6.7</environment>
        <key id="182671">CSHARP-1180</key>
            <summary>The wait queue for acquiring a connection to server is full</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="camak">Casoa Makaso</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 Feb 2015 10:27:24 +0000</created>
                <updated>Mon, 7 Aug 2017 18:14:10 +0000</updated>
                            <resolved>Thu, 5 Feb 2015 13:53:13 +0000</resolved>
                                    <version>2.0</version>
                                                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="1642175" author="jstafford@digitalairstrike.com" created="Mon, 7 Aug 2017 18:13:33 +0000"  >&lt;p&gt;I&apos;m actually encountering an issue with this. The only instance of my trying to write to mongo is throttled with a semaphore. The semaphore is set to only allow 150 concurrent writes and the server is reporting back to me that 226 connections available (before I start) yet I&apos;m still getting this error intermittently.&lt;/p&gt;</comment>
                            <comment id="1291455" author="rstam" created="Sat, 11 Jun 2016 19:11:29 +0000"  >&lt;p&gt;This exception is not necessarily a bug. It just indicates that too many threads are trying to use MongoDB at once. In the example provided in the description the code is trying to do 100,000 inserts in parallel.&lt;/p&gt;

&lt;p&gt;By default the connection pool has 100 connections. Threads pull connections from the connection pool and return them when they are done. Once all connections are in use, any further threads that want a connection must wait for some other thread to return a connection to the pool. The driver limits the number of threads that are allowed to wait for a connection at the same time. The default limit is 500.&lt;/p&gt;

&lt;p&gt;With 100,000 parallel inserts it&apos;s not unexpected that more than 600 threads might be actively trying to do an insert at the same time, which will result in this exception being thrown.&lt;/p&gt;

&lt;p&gt;The solution is to either decrease the number of threads trying to use MongoDB at the same time (decrease the degree of parallelism) or to configure the connection pool to have either more connections or a higher wait queue limit, or both.&lt;/p&gt;

&lt;p&gt;If you see this exception and you &lt;b&gt;know&lt;/b&gt; there are fewer than 600 threads that would be something we would like to reproduce.&lt;/p&gt;</comment>
                            <comment id="1291431" author="babu.james@live.in" created="Sat, 11 Jun 2016 18:16:34 +0000"  >&lt;p&gt;Is it still not fixed, I still get this error from the latest driver.&lt;/p&gt;</comment>
                            <comment id="822193" author="craiggwilson" created="Thu, 5 Feb 2015 13:53:13 +0000"  >&lt;p&gt;Hi Casoa and Ben,&lt;/p&gt;

&lt;p&gt;Thanks for the reports. We have seen this before, but thank you so much for the easy repro. While, it&apos;s somewhat evident what is going on and what is happening (limited resource connection pool and massive quantity of requests all in parallel), we are working through how to make this work. Please track the other ticket for the fix.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                            <comment id="822178" author="benb7760" created="Thu, 5 Feb 2015 13:17:48 +0000"  >&lt;p&gt;I have just encountered the same issue, using collection.Find().ToListAsync instead of InsertAsync&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="173016">CSHARP-1144</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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|hs625j:</customfieldvalue>

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