<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:13 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>[JAVA-2438] com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool</title>
                <link>https://jira.mongodb.org/browse/JAVA-2438</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;We are running multiple threads, which are doing reads and writes operation at same point of time. One of the thread is reading from the database with time filter which is big enough to fetch 111000 records in one shot. The field in indexed in the collection. But, while this query is running it closes the connection pool and resulting the com.mongodb.MongoInterruptedException exception. Can you please tell me in what situation already open cursor will be closed abruptly where application has not initiated any close connection command. Below are the mongo-java-driver logs in trace mode. We are running single node of the mongo-database where mongodb version is 2.6.4 (Also tried with 3.2.8 wiredTiger but no luck) and mongo java driver 3.0.2 with java 8 and radhat linux environment.&lt;/p&gt;

&lt;p&gt;2017/01/28 15:44:41.279 &lt;span class=&quot;error&quot;&gt;&amp;#91;MongoDbUtils&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;SimpleAsyncTaskExecutor-4&amp;#93;&lt;/span&gt;:   DEBUG: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB1BE4B0F200BF2094F1&amp;#93;&lt;/span&gt; Getting Mongo Database name=&lt;span class=&quot;error&quot;&gt;&amp;#91;COLLECTIONNAME&amp;#93;&lt;/span&gt;&lt;br/&gt;
2017/01/28 15:44:41.280 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;SimpleAsyncTaskExecutor-4&amp;#93;&lt;/span&gt;:   TRACE: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB1BE4B0F200BF2094F1&amp;#93;&lt;/span&gt; Checked out connection [connectionId&lt;/p&gt;
{localValue:8, serverValue:3244}
&lt;p&gt;] to server HOST:27017&lt;br/&gt;
2017/01/28 15:44:41.280 &lt;span class=&quot;error&quot;&gt;&amp;#91;update&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;SimpleAsyncTaskExecutor-4&amp;#93;&lt;/span&gt;:   DEBUG: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB1BE4B0F200BF2094F1&amp;#93;&lt;/span&gt; Updating documents in namespace COLLECTIONNAME.scheduled on connection [connectionId&lt;/p&gt;
{localValue:8, serverValue:3244}
&lt;p&gt;] to server HOST:27017&lt;br/&gt;
2017/01/28 15:44:41.286 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   DEBUG: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Closing connection connectionId&lt;/p&gt;
{localValue:10, serverValue:3246}
&lt;p&gt;2017/01/28 15:44:41.289 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   TRACE: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Checked in connection [connectionId&lt;/p&gt;
{localValue:10, serverValue:3246}
&lt;p&gt;] to server HOST:27017&lt;br/&gt;
2017/01/28 15:44:41.289 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   INFO: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Closed connection [connectionId&lt;/p&gt;
{localValue:10, serverValue:3246}
&lt;p&gt;] to HOST:27017 because the pool has been closed.&lt;br/&gt;
2017/01/28 15:44:41.289 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   DEBUG: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Closing connection connectionId&lt;/p&gt;
{localValue:10, serverValue:3246}
&lt;p&gt;2017/01/28 15:44:41.290 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   TRACE: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Checked out connection [connectionId&lt;/p&gt;
{localValue:2, serverValue:3238}
&lt;p&gt;] to server HOST:27017&lt;br/&gt;
2017/01/28 15:44:41.290 &lt;span class=&quot;error&quot;&gt;&amp;#91;killcursor&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   DEBUG: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Killing cursors &lt;span class=&quot;error&quot;&gt;&amp;#91;2428016239190&amp;#93;&lt;/span&gt; on connection [connectionId&lt;/p&gt;
{localValue:2, serverValue:3238}
&lt;p&gt;] to server HOST:27017&lt;br/&gt;
2017/01/28 15:44:41.290 &lt;span class=&quot;error&quot;&gt;&amp;#91;connection&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;pool-2-thread-2&amp;#93;&lt;/span&gt;:   TRACE: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB3DE4B0F200BF2094FC&amp;#93;&lt;/span&gt; Checked in connection [connectionId&lt;/p&gt;
{localValue:2, serverValue:3238}
&lt;p&gt;] to server HOST:27017&lt;br/&gt;
2017/01/28 15:44:41.307 &lt;span class=&quot;error&quot;&gt;&amp;#91;update&amp;#93;&lt;/span&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;SimpleAsyncTaskExecutor-4&amp;#93;&lt;/span&gt;:   DEBUG: &lt;span class=&quot;error&quot;&gt;&amp;#91;588CBB1BE4B0F200BF2094F1&amp;#93;&lt;/span&gt; Update completed&lt;/p&gt;



&lt;p&gt;Caused by: com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool&lt;br/&gt;
        at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:186)&lt;br/&gt;
        at com.mongodb.internal.connection.ConcurrentPool.get(ConcurrentPool.java:126)&lt;br/&gt;
        at com.mongodb.internal.connection.ConcurrentPool.get(ConcurrentPool.java:109)&lt;br/&gt;
        at com.mongodb.internal.connection.PowerOfTwoBufferPool.getBuffer(PowerOfTwoBufferPool.java:77)&lt;br/&gt;
        at com.mongodb.connection.SocketStream.read(SocketStream.java:81)&lt;br/&gt;
        at com.mongodb.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:503)&lt;br/&gt;
        at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:221)&lt;br/&gt;
        at com.mongodb.connection.UsageTrackingInternalConnection.receiveMessage(UsageTrackingInternalConnection.java:102)&lt;br/&gt;
        at com.mongodb.connection.DefaultConnectionPool$PooledConnection.receiveMessage(DefaultConnectionPool.java:416)&lt;br/&gt;
        at com.mongodb.connection.GetMoreProtocol.receiveMessage(GetMoreProtocol.java:112)&lt;br/&gt;
        at com.mongodb.connection.GetMoreProtocol.execute(GetMoreProtocol.java:68)&lt;br/&gt;
        at com.mongodb.connection.GetMoreProtocol.execute(GetMoreProtocol.java:37)&lt;br/&gt;
        at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155)&lt;br/&gt;
        at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219)&lt;br/&gt;
        at com.mongodb.connection.DefaultServerConnection.getMore(DefaultServerConnection.java:194)&lt;br/&gt;
        at com.mongodb.operation.QueryBatchCursor.getMore(QueryBatchCursor.java:197)&lt;br/&gt;
        at com.mongodb.operation.QueryBatchCursor.hasNext(QueryBatchCursor.java:93)&lt;br/&gt;
        at com.mongodb.MongoBatchCursorAdapter.hasNext(MongoBatchCursorAdapter.java:46)&lt;br/&gt;
        at com.mongodb.DBCursor.hasNext(DBCursor.java:152)&lt;br/&gt;
        at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1882)&lt;br/&gt;
        ... 156 more&lt;br/&gt;
     Caused by: java.lang.InterruptedException&lt;br/&gt;
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302)&lt;br/&gt;
        at java.util.concurrent.Semaphore.acquire(Semaphore.java:312)&lt;br/&gt;
        at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:182)&lt;br/&gt;
        ... 175 more&lt;/p&gt;</description>
                <environment>Redhat linux, Java, MongoDB java Driver 3.0.2</environment>
        <key id="350097">JAVA-2438</key>
            <summary>com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="4">Incomplete</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="sulabh84">sulabh</reporter>
                        <labels>
                    </labels>
                <created>Sun, 29 Jan 2017 12:41:31 +0000</created>
                <updated>Wed, 11 Sep 2019 19:11:01 +0000</updated>
                            <resolved>Thu, 22 Jun 2017 16:43:49 +0000</resolved>
                                    <version>3.0.2</version>
                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1487703" author="jeff.yemin" created="Sun, 29 Jan 2017 18:04:07 +0000"  >&lt;p&gt;It has nothing to do with any options that your application is setting.  As documented &lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Semaphore.html#acquire()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt; the only way Semaphore.acquire throws an InterruptedException is if the application calls Thread.interrupt().  I&apos;ve confirmed that the driver never calls Thread.interrupt() itself on any application threads.&lt;/p&gt;</comment>
                            <comment id="1487694" author="sulabh84" created="Sun, 29 Jan 2017 16:12:13 +0000"  >&lt;p&gt;Thanks Jeff for the prompt response. &lt;/p&gt;

&lt;p&gt;Our application is an standalone application which is not calling Thread.interrupt() in the code, So, what could be the ideal max connection per host size and max time out for MongoOptions since we are getting this error, even we had increased minConnectionsPerHost=20000 and connectTimeout=1000*300 but still we saw the same issue?&lt;/p&gt;

&lt;p&gt;Or is there any option in the MongoDB java driver 3.0.2 to set, So that MongoDB Driver will recover automatically from this kind of situation?&lt;/p&gt;</comment>
                            <comment id="1487688" author="jeff.yemin" created="Sun, 29 Jan 2017 15:15:37 +0000"  >&lt;p&gt;The cursor may be closed abruptly when the application (or more generally, the application server) calls Thread.interrupt() on the thread that is iterating the cursor.  It looks something like this:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;while more results available&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   wait for connection from the pool   // this is interruptible&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   wait for byte buffer from the pool   // this is interruptible&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   send message&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   receive message                       // this is interruptible&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   wait for byte buffer from the pool   // this is interruptible&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;At any of those interruptible points a concurrent call to Thread.interrupt() on the iterating thread will result in an InterruptedException being thrown.&lt;/p&gt;</comment>
                            <comment id="1487667" author="sulabh84" created="Sun, 29 Jan 2017 12:56:54 +0000"  >&lt;p&gt;Used MongoDBOption with default configuariont connectionPerHost=100 &amp;amp; maxConnectionTimeout=1000*10&lt;/p&gt;</comment>
                    </comments>
                    <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|hsuea7:</customfieldvalue>

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