<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:36:46 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>[GODRIVER-1613] fix how Pool handles MaxPoolSize</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-1613</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;Under heavy load, using a context with timeout in a find operation, if timeout is reached, derives in a weird behavior of driver connection pool.&lt;br/&gt;
Connections starts to be discarded by timeout and pool fall in a snow ball of discard/reconnect attemps until driver panics.&#160;&lt;br/&gt;
In tests running about 2 minutes, we observe, using a pool monitor, about 27k opened&#160; and 26k closed&#160;connections, with a minPoolSize of 30 and a maxPoolSize of 100.&lt;/p&gt;

&lt;p&gt;To be clear, this is a sniped of code tested:&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;filter := bson.M{&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;store_id&quot;&lt;/span&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;: bson.M{&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;$in&quot;&lt;/span&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;: idsList}}&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;ctx, cancel := context.WithTimeout(context.Background(), &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;500&lt;/span&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;*time.Millisecond)&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;defer cancel()&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;&amp;nbsp;&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;fOptions := options.Find().&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;   SetMaxTime(&lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;500&lt;/span&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;*time.Millisecond).&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;   SetBatchSize(int32(len(idsList)))&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;&amp;nbsp;&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;records, err := m.storesCollection.Find(ctx, filter, fOptions)&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;where:&lt;br/&gt;
idList is a variable length slice of ids to search (indexed field, unique)&lt;br/&gt;
ctx: Problematic context with timeout&lt;br/&gt;
fOptions&#8211;&amp;gt;MaxTime: works ok&lt;/p&gt;


&lt;p&gt;Two files attached:&lt;br/&gt;
1- Test result with metrics and error messages&lt;br/&gt;
2- console output with traces&lt;/p&gt;</description>
                <environment>MacBook Pro with macOs Catalina. Version 10.15.4 (19E287)&lt;br/&gt;
processor: 2,2 GHz Quad-Core Intel Core i7&lt;br/&gt;
memory: 16 GB 1600 MHz DDR3&lt;br/&gt;
Golang version: go1.13.5 darwin/amd64&lt;br/&gt;
Database version: 3.6.17 runnning on docker for tests</environment>
        <key id="1345745">GODRIVER-1613</key>
            <summary>fix how Pool handles MaxPoolSize</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="13201">Fixed</resolution>
                                        <assignee username="isabella.siu@mongodb.com">Isabella Siu</assignee>
                                    <reporter username="gaston.acevedo@rappi.com">Gaston Gregorio Blas Acevedo</reporter>
                        <labels>
                    </labels>
                <created>Sun, 10 May 2020 08:10:05 +0000</created>
                <updated>Sat, 28 Oct 2023 11:38:11 +0000</updated>
                            <resolved>Fri, 5 Jun 2020 21:27:35 +0000</resolved>
                                    <version>1.3.2</version>
                                    <fixVersion>1.3.5</fixVersion>
                                                        <votes>2</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="3205923" author="xgen-internal-githook" created="Thu, 11 Jun 2020 19:49:17 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Divjot Arora&apos;, &apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1613&quot; title=&quot;fix how Pool handles MaxPoolSize&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1613&quot;&gt;&lt;del&gt;GODRIVER-1613&lt;/del&gt;&lt;/a&gt; Improve stability of flaky test (#420)&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1613&quot; title=&quot;fix how Pool handles MaxPoolSize&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1613&quot;&gt;&lt;del&gt;GODRIVER-1613&lt;/del&gt;&lt;/a&gt; Improve stability of flaky test&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;fix typo&lt;br/&gt;
Branch: release/1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/3553c77e3344cd40654d725ea7873e9f2c180a50&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/3553c77e3344cd40654d725ea7873e9f2c180a50&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="3205921" author="xgen-internal-githook" created="Thu, 11 Jun 2020 19:47:48 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Divjot Arora&apos;, &apos;email&apos;: &apos;divjot.arora@10gen.com&apos;, &apos;username&apos;: &apos;divjotarora&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1613&quot; title=&quot;fix how Pool handles MaxPoolSize&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1613&quot;&gt;&lt;del&gt;GODRIVER-1613&lt;/del&gt;&lt;/a&gt; Improve stability of flaky test (#420)&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1613&quot; title=&quot;fix how Pool handles MaxPoolSize&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1613&quot;&gt;&lt;del&gt;GODRIVER-1613&lt;/del&gt;&lt;/a&gt; Improve stability of flaky test&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;fix typo&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/eb83a3b1a0a8b391f44ad67e9a8d4749476c83a4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/eb83a3b1a0a8b391f44ad67e9a8d4749476c83a4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="3193334" author="xgen-internal-githook" created="Fri, 5 Jun 2020 21:27:22 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;iwysiu&apos;, &apos;email&apos;: &apos;isabella.siu@10gen.com&apos;, &apos;username&apos;: &apos;iwysiu&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1613&quot; title=&quot;fix how Pool handles MaxPoolSize&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1613&quot;&gt;&lt;del&gt;GODRIVER-1613&lt;/del&gt;&lt;/a&gt; fix how pool handles MaxPoolSize (#413)&lt;br/&gt;
Branch: release/1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/d89ba217da09bec04910dc1c0cead5288021c540&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/d89ba217da09bec04910dc1c0cead5288021c540&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3193229" author="xgen-internal-githook" created="Fri, 5 Jun 2020 20:37:22 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;iwysiu&apos;, &apos;email&apos;: &apos;isabella.siu@10gen.com&apos;, &apos;username&apos;: &apos;iwysiu&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1613&quot; title=&quot;fix how Pool handles MaxPoolSize&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1613&quot;&gt;&lt;del&gt;GODRIVER-1613&lt;/del&gt;&lt;/a&gt; fix how pool handles MaxPoolSize (#413)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/bbe8c4a0adeb6fc5095d0aa53a7d32a025d368c9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/bbe8c4a0adeb6fc5095d0aa53a7d32a025d368c9&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3191301" author="isabella.siu" created="Thu, 4 Jun 2020 21:30:26 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=gaston.acevedo%40rappi.com&quot; class=&quot;user-hover&quot; rel=&quot;gaston.acevedo@rappi.com&quot;&gt;gaston.acevedo@rappi.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;We&apos;re trying to finish this ticket up by tomorrow morning. The fix in &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1620&quot; title=&quot;pool cleared on network timeout errors&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-1620&quot;&gt;&lt;del&gt;GODRIVER-1620&lt;/del&gt;&lt;/a&gt; was released in v1.3.4, and we believe that it should help with your problem.&lt;/p&gt;</comment>
                            <comment id="3191130" author="JIRAUSER1251103" created="Thu, 4 Jun 2020 20:14:34 +0000"  >&lt;p&gt;Hi Isabella,&lt;/p&gt;

&lt;p&gt;Please can you please, give me some data about the bug in review?&lt;br/&gt;
I can see only one related ticket, already closed: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-1620&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-1620&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TY!&lt;/p&gt;</comment>
                            <comment id="3139630" author="isabella.siu" created="Thu, 28 May 2020 22:25:05 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=gaston.acevedo%40rappi.com&quot; class=&quot;user-hover&quot; rel=&quot;gaston.acevedo@rappi.com&quot;&gt;gaston.acevedo@rappi.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;As an update, one of the two bugs has been fixed and the other one is currently going through review.&lt;/p&gt;</comment>
                            <comment id="3132991" author="JIRAUSER1251103" created="Wed, 27 May 2020 22:53:39 +0000"  >&lt;p&gt;Hi Isabella,&lt;/p&gt;

&lt;p&gt;any update on this topic?&lt;/p&gt;

&lt;p&gt;TY!&lt;/p&gt;</comment>
                            <comment id="3103256" author="isabella.siu" created="Thu, 21 May 2020 21:22:55 +0000"  >&lt;p&gt;Hi&#160;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=gaston.acevedo%40rappi.com&quot; class=&quot;user-hover&quot; rel=&quot;gaston.acevedo@rappi.com&quot;&gt;gaston.acevedo@rappi.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;As an update, we&apos;re currently working on bug fixes that should reduce the number of opened and closed connections. Thanks for all the information!&lt;/p&gt;</comment>
                            <comment id="3096508" author="JIRAUSER1251103" created="Wed, 20 May 2020 01:00:42 +0000"  >&lt;p&gt;&lt;em&gt;We&apos;ve found a potential bug with MaxPoolSize that we are currently investigating. However, regarding the timeouts, an expired context timeout must close the socket and we can&apos;t change that behavior.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;I don&apos;t feel in position to ask you for a change like don&apos;t closing socket at context timeout.&lt;/b&gt; &lt;br/&gt;
 &lt;b&gt;We need a connection pool handling the timeout in a more gentle and predictable manner.&lt;/b&gt; &lt;br/&gt;
 &lt;b&gt;As shown in one of my previous comments, when reach the context timeout, mongostat report connections moving each second between 45, 18, 371, 13, 79, 163, 151, 308. This behaviour translates directly to a microservice auto-scaling (at best) and our infrastructure alarms firing by the miss-behaving instance&#160;and by the global count of connections open.&lt;/b&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;you mention that your mongod/mongos servers don&apos;t show atypical resource consumption&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Our monitoring show us a server&apos;s consumption of resources in the expected range for the system&apos;s load,&lt;/b&gt;&#160;&lt;b&gt;and our timeout is inflexible, we can&apos;t use a best effort timeout as FindOption&apos;s maxTime, so we use the context to end any call reaching the maximum time that we can wait without compromise the SLA.&lt;/b&gt;&#160;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;but the next sentence says that the servers&apos; load pushes response times until the context expires. If the mongod/mongos server has ample resources, can you provide any guesses as to why it&apos;s not responding within the specified MaxTime option&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;In peak hours our maximum timeout is close to average MongoDB&apos;s response time.&lt;/b&gt; &lt;br/&gt;
 &lt;b&gt;Sometimes, a query can excede the timeout and that call is dropped and replaced&#160;with a response from the service&apos;s fallback (probably stale data, but data at least).&lt;/b&gt; &lt;br/&gt;
 &lt;b&gt;The query issued to MongoDB is very simple, find documents by ids&apos; list, using a $in, but the length of ids list is variable from one hundred to four hundred more or less (size depends on user&apos;s context) on each call.&lt;/b&gt; &lt;br/&gt;
 &lt;b&gt;The querys with larger number of documents to return are the most susceptible to reach our timeout.&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="3096308" author="isabella.siu" created="Tue, 19 May 2020 21:59:17 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=gaston.acevedo%40rappi.com&quot; class=&quot;user-hover&quot; rel=&quot;gaston.acevedo@rappi.com&quot;&gt;gaston.acevedo@rappi.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;We&apos;ve found a potential bug with MaxPoolSize that we are currently investigating. However, regarding the timeouts, an expired context timeout must close the socket and we can&apos;t change that behavior.&lt;/p&gt;

&lt;p&gt;Can you provide more explanation about your previous comment? You mention that your mongod/mongos servers don&apos;t show atypical resource consumption, but the next sentence says that the servers&apos; load pushes response times until the context expires. If the mongod/mongos server has ample resources, can you provide any guesses as to why it&apos;s not responding within the specified MaxTime option?&lt;/p&gt;</comment>
                            <comment id="3096266" author="JIRAUSER1251103" created="Tue, 19 May 2020 21:40:55 +0000"  >&lt;p&gt;Hi Isabella,&lt;br/&gt;
Please, can you tell me the next steps?&lt;br/&gt;
We have a lot of expectation about this.&lt;/p&gt;

&lt;p&gt;Thank you in advance&lt;/p&gt;</comment>
                            <comment id="3088771" author="JIRAUSER1251103" created="Thu, 14 May 2020 21:09:24 +0000"  >&lt;p&gt;Monitoring our servers don&apos;t show an atypical resource consumption, in fact never goes over 30% or 40% of Memory or CPU available, but we have a hard constraint in response time and must honor it. So our timeouts are inflexible.&lt;br/&gt;
 The problem arises when servers&apos; load pushes responses times until reach our timeouts and the described behaviour starts:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Continuos recicle of connections&lt;/li&gt;
	&lt;li&gt;Gets from connection&apos;s pool stuck&lt;/li&gt;
	&lt;li&gt;A big number of connections trying to authenticate at same time&lt;/li&gt;
	&lt;li&gt;Application&apos;s code failing and so on.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="3086185" author="divjot.arora" created="Thu, 14 May 2020 15:45:39 +0000"  >&lt;p&gt;You&apos;re setting both but still seeing connection churn? Is it possible that the server is under too much load to respond to requests in a timely manner and by the time it can send a response, the context timeout has expired so the driver has closed the connection?&lt;/p&gt;</comment>
                            <comment id="3086165" author="JIRAUSER1251103" created="Thu, 14 May 2020 15:39:07 +0000"  >&lt;p&gt;Hi Divjot,&lt;br/&gt;
We already set both maxTime in findOptions and contextTimeout, having a contextTimeout with more time than maxTime timeout. Additionally, we were forced to scale up our microservices instances to distribute timeouts and try to keep things running in a barely aceptable way, but clearly this is not the way to go.&lt;/p&gt;

&lt;p&gt;Thanks!&#160;&lt;/p&gt;</comment>
                            <comment id="3086036" author="divjot.arora" created="Thu, 14 May 2020 14:56:33 +0000"  >&lt;p&gt;Thank you for all of the information! One thing to note is that the server can sometimes report more connections than the driver actually has open if it is under load and has not been able to prune the connections that were closed by the driver. Of course, this doesn&apos;t mean there isn&apos;t also a bug with &lt;tt&gt;MaxPoolSize&lt;/tt&gt; in the driver.&lt;/p&gt;

&lt;p&gt;Our plan is to investigate this further and see if we can find cases that cause the driver to create more connections than &lt;tt&gt;MaxPoolSize&lt;/tt&gt;. I&apos;m hoping to get an answer to you early next week. In the meantime, you mentioned that &lt;tt&gt;MaxTime&lt;/tt&gt; works OK for your use case. Can you try setting both &lt;tt&gt;MaxTime&lt;/tt&gt; and a context timeout? I&apos;d recommend setting &lt;tt&gt;MaxTime&lt;/tt&gt; to something slightly shorter than the context timeout so the server has enough time to send a response before the driver receives a network timeout error and closes the connection.&lt;/p&gt;</comment>
                            <comment id="3082532" author="JIRAUSER1251103" created="Wed, 13 May 2020 04:08:30 +0000"  >&lt;p&gt;The mongostat reported is connected to a stand alone MongoDB instance, running on my machine for test, so minPoolSize/maxPoolSize is absolute, i guess.&lt;/p&gt;

&lt;p&gt;I give you the information of our production clusters just to show you the heterogeneous topologies where the same problem shows up.&lt;/p&gt;

&lt;p&gt;I have a golang project to test this at:&#160;&lt;a href=&quot;https://github.com/n4d13/mongo_driver_test&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/n4d13/mongo_driver_test&lt;/a&gt;&lt;br/&gt;
 where i reproduce the usage scenario.&lt;br/&gt;
 Feel free to use it&lt;/p&gt;</comment>
                            <comment id="3082315" author="divjot.arora" created="Tue, 12 May 2020 23:49:25 +0000"  >&lt;p&gt;The pool size applies to the each node, not the total number of connections to the cluster overall. So that means if you have max pool size of 100 and a 5 node cluster, the driver will create up to 500 application connections total. This will actually be something like 505 connections reported by mongostat because we also keep one dedicated connection per-node that&apos;s used for monitoring and detecting state changes.&lt;/p&gt;

&lt;p&gt;I might be misunderstanding something from your response, but we need to know if the mongostat connection is to a single node or to the cluster as a whole, as this will influence the number of connections reported by the tool. See&#160;&lt;a href=&quot;https://docs.mongodb.com/manual/reference/program/mongostat/#cmdoption-mongostat-host&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.com/manual/reference/program/mongostat/#cmdoption-mongostat-host&lt;/a&gt;&#160;for some more information about this.&lt;/p&gt;

&lt;p&gt;Can you provide this information?&lt;/p&gt;</comment>
                            <comment id="3081749" author="JIRAUSER1251103" created="Tue, 12 May 2020 19:29:00 +0000"  >&lt;p&gt;Hi Divjot,&#160;&lt;br/&gt;
We have a set of 9 production deployments with MongoDB version 3.6 in AWS, 9 production deployments using DocumentDB in AWS compatibility with version 3.6 of MongoDB certified, and a test running local on my machine. All of them show the same behaviour.&lt;/p&gt;

&lt;p&gt;The Topology for MongoDB in production is:&lt;br/&gt;
Replicaset of 5 nodes -&#160;&#160;r5.4xlarge&#160;(4 cores, 32Gb RAM, network 10Gbps, bandwidth of storage 4750 mbps)&lt;/p&gt;

&lt;p&gt;The Topology for DocumentDB in production is:&lt;br/&gt;
Replicaset of 5 nodes - db.m5.8xlarge for writer and 4 db.m5.xlarge for readers&lt;/p&gt;

&lt;p&gt;On local, im running with specifications:&lt;br/&gt;
MacBook Pro with macOs Catalina. Version 10.15.4 (19E287)&lt;br/&gt;
processor: 2,2 GHz Quad-Core Intel Core i7&lt;br/&gt;
memory: 16 GB 1600 MHz DDR3&lt;br/&gt;
Golang version: go1.13.5 darwin/amd64&lt;br/&gt;
Database version: 3.6.17 running on docker for tests&lt;/p&gt;


&lt;p&gt;That mongostat, logs and tests results are the result of running tests in local.&lt;br/&gt;
To help you i can share the tests project developed to investigate this case, just tell me.&lt;/p&gt;

&lt;p&gt;Thanks in advance!&lt;/p&gt;</comment>
                            <comment id="3080724" author="divjot.arora" created="Tue, 12 May 2020 14:17:11 +0000"  >&lt;p&gt;How many nodes are in the cluseter? Is mongostat connected directly to a mongod/mongos or is it making a replica set connection, where it auto-discovers the nodes?&lt;/p&gt;</comment>
                            <comment id="3079927" author="JIRAUSER1251103" created="Tue, 12 May 2020 01:47:05 +0000"  >&lt;p&gt;Hi Divjot, ty for your response.&lt;br/&gt;
Just to clarify about our scenario... we have a hard time constraint and best effort timeout translates to, for example, opened circuits breakers, fallbacks called, increased response times and so on.&lt;br/&gt;
Maybe, some timeouts don&apos;t hurts, but when we reach this timeout scenario, suddenly we face the connections discard/reconnect mechanics with mongostat showing us an erratic behaviour.&lt;br/&gt;
Having a pool configured with min = 30 and max = 100 connections, and seeing, second to second, mongostat&apos;s report of connections open:&lt;br/&gt;
18&lt;br/&gt;
371&lt;br/&gt;
13&lt;br/&gt;
79&lt;br/&gt;
163&lt;br/&gt;
151&lt;br/&gt;
308&lt;br/&gt;
and process died..&lt;/p&gt;



&lt;p&gt;At bottom i pasted mongostat output &apos;cause Jira don&apos;t let me attach another file. Sorry.&lt;/p&gt;

&lt;p&gt;&#160;&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;insert query update delete getmore command dirty used flushes vsize &#160; res qrw&#160; arw net_in net_out conn&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; time&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;&#160; &#160; *0&#160; &#160; 24 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 594|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.21G&#160; 118M 0|0&#160; 1|0 &#160; 390k &#160; 3.53m &#160; 23 May 12 01:32:53.069&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;&#160; &#160; *0&#160; &#160; 30 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 708|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 473k &#160; 4.08m &#160; 39 May 12 01:32:54.139&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;&#160; &#160; *0&#160; &#160; 39 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 5 &#160; 716|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 544k &#160; 4.93m &#160; 14 May 12 01:32:55.075&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;&#160; &#160; *0&#160; &#160; 45 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 5 &#160; 737|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 4|0 &#160; 668k &#160; 5.86m &#160; 22 May 12 01:32:56.036&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;&#160; &#160; *0&#160; &#160; 52 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 2 &#160; 683|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.21G&#160; 118M 0|0&#160; 1|0 &#160; 730k &#160; 7.76m &#160; 45 May 12 01:32:57.056&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;&#160; &#160; *0&#160; &#160; 37 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 6 &#160; 720|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 3|0 &#160; 543k &#160; 4.65m &#160; 18 May 12 01:32:58.040&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;&#160; &#160; *0 &#160; &#160; 9 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 428|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.52G&#160; 121M 0|0&#160; 1|0 &#160; 199k &#160; 1.65m&#160; 371 May 12 01:32:59.118&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;&#160; &#160; *0 &#160; &#160; 6 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 164|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 109k &#160; 1.00m &#160; 13 May 12 01:33:00.104&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;&#160; &#160; *0&#160; &#160; 67 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 471|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.24G&#160; 119M 0|0&#160; 1|0 &#160; 841k &#160; 9.15m &#160; 79 May 12 01:33:01.029&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;&#160; &#160; *0&#160; &#160; 63 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 2 &#160; 334|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.33G&#160; 120M 0|0&#160; 3|0 &#160; 725k &#160; 7.76m&#160; 163 May 12 01:33:02.073&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;insert query update delete getmore command dirty used flushes vsize &#160; res qrw&#160; arw net_in net_out conn&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; time&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;&#160; &#160; *0&#160; &#160; 21 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 534|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.31G&#160; 119M 0|0&#160; 1|0 &#160; 326k &#160; 3.09m&#160; 151 May 12 01:33:02.995&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;&#160; &#160; *0&#160; &#160; 11 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 414|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.48G&#160; 122M 0|0&#160; 1|0 &#160; 229k &#160; 1.81m&#160; 308 May 12 01:33:04.229&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 448|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0&#160; 98.8k&#160; &#160; 187k&#160; &#160; 2 May 12 01:33:04.996&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; 134|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0&#160; 29.5k &#160; 93.2k&#160; &#160; 2 May 12 01:33:05.996&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; &#160; 1|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 157b &#160; 61.1k&#160; &#160; 2 May 12 01:33:07.002&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0&#160; &#160; 44|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0&#160; 9.47k &#160; 71.7k&#160; &#160; 2 May 12 01:33:07.998&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; &#160; 2|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 158b &#160; 61.5k&#160; &#160; 2 May 12 01:33:08.997&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; &#160; 1|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 157b &#160; 61.3k&#160; &#160; 2 May 12 01:33:09.999&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0&#160; &#160; 75|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0&#160; 16.3k &#160; 79.1k&#160; &#160; 2 May 12 01:33:10.996&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;&#160; &#160; *0&#160; &#160; *0 &#160; &#160; *0 &#160; &#160; *0 &#160; &#160; &#160; 0 &#160; &#160; 2|0&#160; 0.0% 1.8% &#160; &#160; &#160; 0 1.20G&#160; 118M 0|0&#160; 1|0 &#160; 158b &#160; 61.4k&#160; &#160; 2 May 12 01:33:11.996&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;&#160;&lt;/p&gt;</comment>
                            <comment id="3079710" author="divjot.arora" created="Mon, 11 May 2020 21:47:59 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=gaston.acevedo%40rappi.com&quot; class=&quot;user-hover&quot; rel=&quot;gaston.acevedo@rappi.com&quot;&gt;gaston.acevedo@rappi.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for the detailed report. We don&apos;t think this is a bug. The driver implements context timeouts by translating the context deadline to a socket timeout using the the &lt;tt&gt;SetReadDeadline&lt;/tt&gt; and &lt;tt&gt;SetWriteDeadline&lt;/tt&gt; functions on the &lt;tt&gt;net.Conn&lt;/tt&gt; interface. If the read or write gets a socket timeout error, we have to close the connection for two reasons:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;To let the server know that it can stop doing the work for the operation. The server polls its open connections and can interrupt in-progress work at designated points if the client has closed the connection.&lt;/li&gt;
	&lt;li&gt;To free up system resources that may be storing part or all of the server response. If the timeout happens after the server has already starting writing the response, we don&apos;t know the state of the socket. We can&apos;t reuse it because the server may already have written the response, so future reads would read responses from previous requests.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;As you mentioned, the &lt;tt&gt;MaxTime&lt;/tt&gt; option would be better for this use-case, as it only limits the amount of time the server spends on the operation and does not cause the socket to be closed if the operation fails. Note that you may want to use both &lt;tt&gt;MaxTime&lt;/tt&gt; and a context timeout (or the &lt;tt&gt;SocketTimeout&lt;/tt&gt; Client option) because &lt;tt&gt;MaxTime&lt;/tt&gt; is best-effort. The socket timeout should be an upper-bound. If the server hasn&apos;t replied by then, we can close the connection.&lt;/p&gt;

&lt;p&gt;We do have an ongoing drivers-wide project to consolidate the many drivers timeout options. The project is still being scoped/designed, but part of it may involve using the context timeout or other timeouts provided through various options to set &lt;tt&gt;maxTimeMS&lt;/tt&gt; on commands we send to the server to avoid this kind of connection churn.&lt;/p&gt;

&lt;p&gt;Does this clarify what&apos;s going on in the driver and why &lt;tt&gt;MaxTime&lt;/tt&gt; works for your use case?&lt;/p&gt;

&lt;p&gt;&#8211; Divjot&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1357167">GODRIVER-1620</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="259378" name="Test_result.zip" size="12208" author="gaston.acevedo@rappi.com" created="Sun, 10 May 2020 08:09:54 +0000"/>
                            <attachment id="259379" name="console.zip" size="25452" author="gaston.acevedo@rappi.com" created="Sun, 10 May 2020 08:09:54 +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|hr777b:</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>