<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:21:14 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-4545] Heartbeat poll cannot be canceled</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-4545</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;h4&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Destruction of &quot;topology-&amp;gt;server_monitors&quot; can take up to 500ms, as the server is making a blocking heartbeat poll that cannot be canceled for 500ms (MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;That makes mongoc quite slow to run in unit tests, as every case takes around 500ms.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Environment&quot;&gt;&lt;/a&gt;Environment&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Driver Versions 1.21.0-1.22.2. Probably older versions too.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;System: Ubuntu 20.04 x64 and Windows 10 x64.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Compiler: GCC 9.3.0 and MSBuild v141.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Server version: 4.4.12.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;HowtoReproduce&quot;&gt;&lt;/a&gt;How to Reproduce&lt;/h4&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;em&gt;Initialize mongoc driver;&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Create mongoc client pool;&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Connect to MongoDB using the pool;&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Destroy the pool.&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&lt;em&gt;Actual result: mongoc_client_pool_destroy takes 500ms.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;AdditionalBackground&quot;&gt;&lt;/a&gt;Additional Background&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;It looks like the heartbeat implemented in the way that client sends the heartbeat to the server and then relies on the server to send response in10 seconds, but not later than in 20 seconds. While waiting for the server&apos;s response the client polls the socket with 500ms intervals. Those intervals are blocking and cannot be cancelled. And there is no way to set heartbeat interval less than 500ms (Error parsing URI: &apos;Invalid &quot;heartbeatfrequencyms&quot; of 1: must be at least 500&apos;).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I feel like there should be an option to either cancel the poll, or make it much smaller if we want to keep it blocking.&lt;/em&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2214387">CDRIVER-4545</key>
            <summary>Heartbeat poll cannot be canceled</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="valentin.garaschuk@gmail.com">Valentin Garaschuk</reporter>
                        <labels>
                            <label>techdebt</label>
                    </labels>
                <created>Sat, 17 Dec 2022 03:43:59 +0000</created>
                <updated>Fri, 10 Feb 2023 15:46:09 +0000</updated>
                                            <version>1.23.1</version>
                                                    <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="5186864" author="JIRAUSER1269924" created="Fri, 10 Feb 2023 15:46:09 +0000"  >&lt;p&gt;Thanks for the additional info, Valentin! This is helpful. &lt;/p&gt;</comment>
                            <comment id="5186839" author="JIRAUSER1272337" created="Fri, 10 Feb 2023 15:39:47 +0000"  >&lt;p&gt;Hi Rishabh, unfortunately I was not able to use &lt;em&gt;mongoc-interrupt-private.h.&lt;/em&gt; Once I try to include it, it also includes other headers, which trigger compilation error that says something like &quot;this header can only be included via &lt;em&gt;mongoc.h.&lt;/em&gt; However&#160;&lt;em&gt;mongoc.h&lt;/em&gt;&#160;itself does not include &lt;em&gt;mongoc-interrupt-private.h.&lt;/em&gt; Also the functions in &lt;em&gt;mongoc-interrupt-private.h&lt;/em&gt;&#160; are not exported, so I cannot import them from a binary. Also my project links mongocxx, it does not use mongoc directly, so it makes the matter even more complicated.&lt;/p&gt;

&lt;p&gt;However, it looks like the code in&#160; &lt;em&gt;mongoc-interrupt-private.h&lt;/em&gt;&#160;does exactly what I need. So it would be nice if it was automatically triggered by mongoc when the poll needs to be interrupted.&lt;/p&gt;</comment>
                            <comment id="5186535" author="JIRAUSER1269924" created="Fri, 10 Feb 2023 14:27:03 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=valentin.garaschuk%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;valentin.garaschuk@gmail.com&quot;&gt;valentin.garaschuk@gmail.com&lt;/a&gt; , just checking in - did the &lt;em&gt;mongoc-interrupt-private.h&lt;/em&gt;&#160;suggestion fixed the issue for you?&lt;/p&gt;</comment>
                            <comment id="5067521" author="JIRAUSER1272337" created="Tue, 20 Dec 2022 15:31:42 +0000"  >&lt;blockquote&gt;&lt;p&gt;Does this refer to tests in the C driver? Or external tests written that use the C driver?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I was referring to the external tests that use the driver.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;there is an unused mongoc-interrupt-private.h that may solve this&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I will check that.&lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;</comment>
                            <comment id="5067478" author="kevin.albertson" created="Tue, 20 Dec 2022 15:23:09 +0000"  >&lt;p&gt;Hello &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=valentin.garaschuk%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;valentin.garaschuk@gmail.com&quot;&gt;valentin.garaschuk@gmail.com&lt;/a&gt;, thank you for the report.&lt;/p&gt;

&lt;p&gt;The 500ms delay on destroy is expected. Checks in between socket polls &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/d1134294420514f4308507ff5b2a5f4764d93c73/src/libmongoc/src/mongoc/mongoc-server-monitor.c#L491&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;are 500ms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;IIRC this caveat was considered when adding polling, but not considered a blocker. &lt;tt&gt;mongoc_client_pool_t&lt;/tt&gt; is expected to live for the duration of an application, so the delay on &lt;tt&gt;mongoc_client_pool_destroy&lt;/tt&gt; is expected to occur only once at application shutdown.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;That makes mongoc quite slow to run in unit tests, as every case takes around 500ms.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Does this refer to tests in the C driver? Or external tests written that use the C driver?&lt;/p&gt;

&lt;p&gt;Opening this ticket for future consideration. Adding a test-only mechanism may speed up C driver tests. Also consider: there is an unused mongoc-interrupt-private.h that may solve this. It may provide a way to interrupt the call to &lt;tt&gt;mongoc_stream_poll&lt;/tt&gt;.&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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>CDRIVER-3870</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr6i7r:f0i6xo</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>