<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:09:49 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-541] Timeout used as specified by connectTimeoutMS will actually be less</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-541</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;The value used as specified by the connectTimeoutMS option you specify will actually be less.&lt;/p&gt;

&lt;p&gt;In mongoc-client.c::mongoc_client_connect_tcp() we have&lt;/p&gt;

&lt;p&gt;104    expire_at = bson_get_monotonic_time () + (connecttimeoutms * 1000L);&lt;/p&gt;

&lt;p&gt;That value is then eventually passed down to mongoc-socket.c::_mongoc_socket_wait() where we have&lt;/p&gt;

&lt;p&gt;133       timeout = (int)((expire_at - bson_get_monotonic_time ()) / 1000L);&lt;/p&gt;

&lt;p&gt;Obviously at this point some amount of time will have already passed, so the time out will be less than what was specified. I&apos;m seeing some quite large variations, with a connectTimeoutMS=100 I have seen the actual time out as low as 2.&lt;/p&gt;

&lt;p&gt;Also, seeing as the time out argument to poll(2) is simply a duration in milliseconds, as quoted from the man page&lt;/p&gt;

&lt;p&gt;&quot;The timeout argument specifies the minimum number of milliseconds that&lt;br/&gt;
       poll() will block.&quot;&lt;/p&gt;

&lt;p&gt;Is there any reason to not just pass the connectTimeoutMS value as is?&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Andrew&lt;/p&gt;</description>
                <environment>CentOS 6.x / x86-64&lt;br/&gt;
&lt;br/&gt;
glibc 2.12 / gcc 4.4.7</environment>
        <key id="185969">CDRIVER-541</key>
            <summary>Timeout used as specified by connectTimeoutMS will actually be less</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="ac000">Andrew Clayton</reporter>
                        <labels>
                    </labels>
                <created>Tue, 24 Feb 2015 19:14:31 +0000</created>
                <updated>Wed, 19 Oct 2016 14:15:05 +0000</updated>
                            <resolved>Thu, 1 Sep 2016 17:37:19 +0000</resolved>
                                    <version> 1.0.2 </version>
                                    <fixVersion>1.5.0</fixVersion>
                                    <component>libmongoc</component>
                    <component>network</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1374771" author="xgen-internal-githook" created="Thu, 1 Sep 2016 17:37:32 +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-541&quot; title=&quot;Timeout used as specified by connectTimeoutMS will actually be less&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-541&quot;&gt;&lt;del&gt;CDRIVER-541&lt;/del&gt;&lt;/a&gt; start connectTimeoutMS after getaddrinfo&lt;/p&gt;

&lt;p&gt;Also restart the timer for each interface attempted, e.g. if the driver&lt;br/&gt;
attempts IPv6, then IPv4.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/9cec261599ce928e1151fd5dbf7360fe96265b85&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/9cec261599ce928e1151fd5dbf7360fe96265b85&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1372655" author="ac000" created="Tue, 30 Aug 2016 21:51:13 +0000"  >&lt;p&gt;Ah, right you are. So yes, the next best thing would be to do the calculation at the last possible moment.&lt;/p&gt;</comment>
                            <comment id="1372623" author="jesse" created="Tue, 30 Aug 2016 21:09:21 +0000"  >&lt;p&gt;Thanks Andrew, unfortunately this signature is now in our public API:&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;int              mongoc_socket_connect    (mongoc_socket_t       *sock,&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;                                           const struct sockaddr *addr,&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;                                           socklen_t              addrlen,&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;                                           int64_t                expire_at);&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;... so we can&apos;t change it, we have to convert from timeoutms to expire_at and back to a timeout in milliseconds.&lt;/p&gt;</comment>
                            <comment id="1372550" author="ac000" created="Tue, 30 Aug 2016 20:08:49 +0000"  >&lt;p&gt;So it&apos;s been a while since I last looked at this. But I&apos;ll ask my last point again.&lt;/p&gt;

&lt;p&gt;Seeing as the timeout argument to poll(2) is simply a duration in milliseconds, as quoted from the man page&lt;/p&gt;

&lt;p&gt;&quot;The  timeout  argument specifies the number of milliseconds that poll()&lt;br/&gt;
  should block waiting for a file descriptor to become ready.&quot;&lt;/p&gt;

&lt;p&gt;So would the simple (and correct) fix be to just pass the specified timeout value straight to poll?&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Andrew&lt;/p&gt;</comment>
                            <comment id="1372467" author="jesse" created="Tue, 30 Aug 2016 19:12:00 +0000"  >&lt;p&gt;It appears this code has &lt;b&gt;not&lt;/b&gt; changed. The variations you see must be the result of calculating expire_at before calling getaddrinfo. So the connect timeout applies to the getaddrinfo call plus the actual TCP connect. As you say, getaddrinfo&apos;s duration is unpredictable and some time can pass before we call connect().&lt;/p&gt;

&lt;p&gt;I think the answer is to calculate expire_at after calling getaddrinfo. This is more like how other drivers work and probably matches the purpose of connect timeout: to distinguish between a slow server and an unavailable one, based on what you know about your network&apos;s typical latency.&lt;/p&gt;</comment>
                            <comment id="1067996" author="jesse" created="Thu, 22 Oct 2015 16:18:20 +0000"  >&lt;p&gt;Need to check this over again, timeouts and the whole network layer of the driver have been overhauled twice since this bug was reported.&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|hrf7hr:</customfieldvalue>

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