<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:12:55 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>[CDRIVER-1571] Spurious topology-scanner timeouts when using stream initiator</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-1571</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;Async &quot;ismaster&quot; commands started before a slow call to a blocking stream initiator have the initiator&apos;s duration subtracted from their timeouts. The initiator and the async commands use the same initial timeout value, so once an initiator times out, all async commands started beforehand now have 0 seconds remaining. They&apos;re canceled before they run.&lt;/p&gt;

&lt;p&gt;Diagnosed with the PHP Driver 1.1.8 and C Driver 1.3.5. The new PHP Driver will no longer use custom stream initiators. Another library could theoretically use them and hit this bug.&lt;/p&gt;

&lt;p&gt;Scenario: create a single client with URI &quot;mongodb://host1,host2/?replicaSet=rs&quot;. host1 is up, host2 is unresponsive.&lt;/p&gt;

&lt;p&gt;With mongoc_client_set_stream_initiator set a custom stream initiator that does a blocking initial connect. Begin an application operation to trigger server selection and a topology scan.&lt;/p&gt;

&lt;p&gt;In mongoc_topology_scanner_start:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Create a stream for host1&lt;/li&gt;
	&lt;li&gt;Call mongoc_async_cmd_new at Time 0&lt;/li&gt;
	&lt;li&gt;mongoc_async_cmd_new sets expiration for calling ismaster on host1 to Time 0 + 10 seconds&lt;/li&gt;
	&lt;li&gt;Create a stream for host2 - this blocks for 10 seconds and fails&lt;/li&gt;
	&lt;li&gt;The time is now after Time 0 + 10 seconds&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Proceed to _mongoc_topology_run_scanner:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;The async command for host1 is already expired, mark it failed&lt;/li&gt;
	&lt;li&gt;We never created an async command for host2 since its initiator timed out&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The C Driver&apos;s error is like:&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;   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;No suitable servers found (`serverselectiontryonce` set): [connection timeout calling ismaster on &apos;host1:27017&apos;] [Failed connecting to &apos;host2:27017&apos;: Connection timed out]&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;The part of the error message about host1 comes from the topology scanner, it&apos;s created when the async command is canceled. The part about host2 comes from the custom stream initiator, in this case I&apos;ve copied the error message formatted by the PHP Driver&apos;s custom stream initiator.&lt;/p&gt;

&lt;p&gt;In the particular scenario that led to me diagnosing this bug, the C Driver also suffered from &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1567&quot; title=&quot;&amp;quot;connection timeout&amp;quot; / &amp;quot;connection error&amp;quot; messages swapped&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1567&quot;&gt;&lt;del&gt;CDRIVER-1567&lt;/del&gt;&lt;/a&gt; so the first part of the message wrongly said &quot;connection error&quot;, but it should have said &quot;connection timeout&quot;.&lt;/p&gt;

&lt;p&gt;The solution is to stop tracking per-command timeouts; they&apos;re intended for a future full-async driver that we&apos;ve decided not to implement. We already track a timeout for _mongoc_topology_run_scanner, which does what we need now.&lt;/p&gt;</description>
                <environment></environment>
        <key id="320069">CDRIVER-1571</key>
            <summary>Spurious topology-scanner timeouts when using stream initiator</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="jesse@mongodb.com">A. Jesse Jiryu Davis</reporter>
                        <labels>
                    </labels>
                <created>Fri, 30 Sep 2016 12:42:21 +0000</created>
                <updated>Thu, 20 Oct 2016 17:02:52 +0000</updated>
                            <resolved>Wed, 5 Oct 2016 01:29:18 +0000</resolved>
                                    <version>1.2.0</version>
                                    <fixVersion>1.3.6</fixVersion>
                    <fixVersion>1.5.0</fixVersion>
                                    <component>libmongoc</component>
                    <component>network</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="1406579" author="xgen-internal-githook" created="Wed, 12 Oct 2016 18:10:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;ajdavis&apos;, u&apos;name&apos;: u&apos;A. Jesse Jiryu Davis&apos;, u&apos;email&apos;: u&apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1571&quot; title=&quot;Spurious topology-scanner timeouts when using stream initiator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1571&quot;&gt;&lt;del&gt;CDRIVER-1571&lt;/del&gt;&lt;/a&gt; simplify async command loop&lt;/p&gt;

&lt;p&gt;mongoc_async_run() no longer returns &quot;true&quot; if there is more work to do:&lt;br/&gt;
it never returns early now since there is only one timeout for the whole&lt;br/&gt;
function. Also, make timeouts int64_t in all internal functions.&lt;br/&gt;
Branch: r1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/f39b4776635c152a93a2d943a23480577f71fb66&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/f39b4776635c152a93a2d943a23480577f71fb66&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1406577" author="xgen-internal-githook" created="Wed, 12 Oct 2016 18:10:57 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;bjori&apos;, u&apos;name&apos;: u&apos;Hannes Magnusson&apos;, u&apos;email&apos;: u&apos;bjori@php.net&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1571&quot; title=&quot;Spurious topology-scanner timeouts when using stream initiator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1571&quot;&gt;&lt;del&gt;CDRIVER-1571&lt;/del&gt;&lt;/a&gt; Add missing r1.3 required includes&lt;br/&gt;
Branch: r1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/ff1ce0ad16d628bf26f01d5b630a3f4533504faf&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/ff1ce0ad16d628bf26f01d5b630a3f4533504faf&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1406576" author="xgen-internal-githook" created="Wed, 12 Oct 2016 18:10:56 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;ajdavis&apos;, u&apos;name&apos;: u&apos;A. Jesse Jiryu Davis&apos;, u&apos;email&apos;: u&apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1571&quot; title=&quot;Spurious topology-scanner timeouts when using stream initiator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1571&quot;&gt;&lt;del&gt;CDRIVER-1571&lt;/del&gt;&lt;/a&gt; slow initiator cancels topology scan&lt;/p&gt;

&lt;p&gt;Async ismaster commands started before a slow call to a blocking stream&lt;br/&gt;
initiator had the initiator&apos;s duration subtracted from their timeouts.&lt;br/&gt;
The initiator and the async commands use the same initial timeout value,&lt;br/&gt;
so once an initiator times out, all async commands started beforehand&lt;br/&gt;
now have 0 seconds remaining. They&apos;re canceled before they run.&lt;/p&gt;

&lt;p&gt;This change relies on the overall timeout applied to mongoc_async_run&lt;br/&gt;
instead of per-command timeouts.&lt;br/&gt;
Branch: r1.3&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/08e4cc9bf92cee2199fad2beeb4c7fd5659ae7ae&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/08e4cc9bf92cee2199fad2beeb4c7fd5659ae7ae&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1400435" author="xgen-internal-githook" created="Wed, 5 Oct 2016 01:28:50 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;ajdavis&apos;, u&apos;name&apos;: u&apos;A. Jesse Jiryu Davis&apos;, u&apos;email&apos;: u&apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1571&quot; title=&quot;Spurious topology-scanner timeouts when using stream initiator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1571&quot;&gt;&lt;del&gt;CDRIVER-1571&lt;/del&gt;&lt;/a&gt; simplify async command loop&lt;/p&gt;

&lt;p&gt;mongoc_async_run() no longer returns &quot;true&quot; if there is more work to do:&lt;br/&gt;
it never returns early now since there is only one timeout for the whole&lt;br/&gt;
function. Also, make timeouts int64_t in all internal functions.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/5cf7749b33d7d976e5b47979f4fc30a9c2594c71&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/5cf7749b33d7d976e5b47979f4fc30a9c2594c71&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1400175" author="jmikola@gmail.com" created="Tue, 4 Oct 2016 20:56:23 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jesse&quot; class=&quot;user-hover&quot; rel=&quot;jesse&quot;&gt;jesse&lt;/a&gt;: Last week, another user reported an issue with what appeared to be unexpected timeouts (incorrectly reported as &quot;connection errors&quot;) on available nodes when a passive node (not in the URI seed list) was unavailable (see: &lt;a href=&quot;https://github.com/mongodb/mongo-php-driver/issues/425&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongodb/mongo-php-driver#425&lt;/a&gt;). In this case, the user appeared to be trying to select a secondary server (&quot;secondaryPreferred&quot; read preference); however, I expect at least one node in the seed list would need to have responded to an &lt;tt&gt;isMaster&lt;/tt&gt; command in order for the topology to discover the passive node.&lt;/p&gt;

&lt;p&gt;Do you suppose this is related? At the very least, it may make for another test case to add for the fix.&lt;/p&gt;
</comment>
                            <comment id="1400138" author="xgen-internal-githook" created="Tue, 4 Oct 2016 20:34:26 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;ajdavis&apos;, u&apos;name&apos;: u&apos;A. Jesse Jiryu Davis&apos;, u&apos;email&apos;: u&apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1571&quot; title=&quot;Spurious topology-scanner timeouts when using stream initiator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1571&quot;&gt;&lt;del&gt;CDRIVER-1571&lt;/del&gt;&lt;/a&gt; slow initiator cancels topology scan&lt;/p&gt;

&lt;p&gt;Async ismaster commands started before a slow call to a blocking stream&lt;br/&gt;
initiator had the initiator&apos;s duration subtracted from their timeouts.&lt;br/&gt;
The initiator and the async commands use the same initial timeout value,&lt;br/&gt;
so once an initiator times out, all async commands started beforehand&lt;br/&gt;
now have 0 seconds remaining. They&apos;re canceled before they run.&lt;/p&gt;

&lt;p&gt;This change relies on the overall timeout applied to mongoc_async_run&lt;br/&gt;
instead of per-command timeouts.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/a5a02711aab0e8d01e16faf7b0d63ca5219292d6&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/a5a02711aab0e8d01e16faf7b0d63ca5219292d6&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1397622" author="jesse" created="Fri, 30 Sep 2016 14:59:20 +0000"  >&lt;p&gt;Yeah if you read the &quot;scenario&quot; above it shows why order matters. Async commands&apos; expiration times are calculated based on when the commands are created.&lt;/p&gt;</comment>
                            <comment id="1397569" author="jmikola@gmail.com" created="Fri, 30 Sep 2016 14:23:10 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jesse&quot; class=&quot;user-hover&quot; rel=&quot;jesse&quot;&gt;jesse&lt;/a&gt;: In my &lt;a href=&quot;https://gist.github.com/jmikola/111994d5867058a2bdce28bbe83950de&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;test to demonstrate the bug&lt;/a&gt;, I was using a one second connection timeout. Am I correct in assuming that the async commands are using the same timeout and that is one one failed, blocking connect attempt is enough to cause each async command to prematurely fail?&lt;/p&gt;

&lt;p&gt;Were you able to determine why the order of nodes in the seed list was significant? That is, async commands only fail for hosts listed before the unavailable host.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="322135">CDRIVER-1682</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="325656">PHPC-820</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|hsqbzb:</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>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1255">C Driver 2016 sprint 8</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>