<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:17:18 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-3166] Clarify requirements around returning clients to a pool before destroying the pool</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-3166</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;Per recent conversation with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jmikola&quot; class=&quot;user-hover&quot; rel=&quot;jmikola&quot;&gt;jmikola&lt;/a&gt; in #mongoc, it&apos;s unclear what happens if you don&apos;t return all the &lt;tt&gt;mongoc_client_t&lt;/tt&gt; s checked out from a pool before you call &lt;tt&gt;mongoc_client_pool_destroy&lt;/tt&gt; on the pool.&#160;&lt;/p&gt;

&lt;p&gt;From my limited testing, it appears that the pool will be destroyed without complaint and attempting to use any still-checked out clients will lead to a server selection error.&lt;/p&gt;

&lt;p&gt;If it&apos;s required that all clients are returned to the pool before it&apos;s destroyed, this should be documented.&lt;/p&gt;

&lt;p&gt;Alternatively, maybe it&apos;s acceptable for the user to just manually destroy a still-checked out client with&#160;&lt;tt&gt;mongoc_client_destroy&lt;/tt&gt;&#160;if they discover this occurred.&#160;&lt;/p&gt;

&lt;p&gt;Either way it would be helpful for the documentation to clarify this.&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="787565">CDRIVER-3166</key>
            <summary>Clarify requirements around returning clients to a pool before destroying the pool</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="kevin.albertson@mongodb.com">Kevin Albertson</assignee>
                                    <reporter username="kaitlin.mahar@mongodb.com">Kaitlin Mahar</reporter>
                        <labels>
                            <label>neweng</label>
                    </labels>
                <created>Mon, 3 Jun 2019 17:20:13 +0000</created>
                <updated>Sat, 28 Oct 2023 11:29:15 +0000</updated>
                            <resolved>Tue, 4 Feb 2020 14:43:24 +0000</resolved>
                                                    <fixVersion>1.17.0-beta</fixVersion>
                    <fixVersion>1.17.0</fixVersion>
                                    <component>docs</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2782427" author="xgen-internal-githook" created="Tue, 4 Feb 2020 14:40:33 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;kevinAlbs&apos;, &apos;name&apos;: &apos;Kevin Albertson&apos;, &apos;email&apos;: &apos;kevin.albertson@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3166&quot; title=&quot;Clarify requirements around returning clients to a pool before destroying the pool&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3166&quot;&gt;&lt;del&gt;CDRIVER-3166&lt;/del&gt;&lt;/a&gt; doc pool/client push/destroy&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/7e801593f2bcf0b26178e3d775be295c612e110f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/7e801593f2bcf0b26178e3d775be295c612e110f&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2777506" author="kevin.albertson" created="Fri, 31 Jan 2020 19:45:46 +0000"  >
&lt;p&gt;If the parent &lt;tt&gt;mongoc_client_pool_t&lt;/tt&gt; is destroyed, you cannot call &lt;tt&gt;mongoc_client_destroy&lt;/tt&gt; on a &lt;tt&gt;mongoc_client_t&lt;/tt&gt;. The shared topology object is destroyed in &lt;tt&gt;mongoc_client_pool_t&lt;/tt&gt;, and calling &lt;tt&gt;mongo_client_destroy&lt;/tt&gt; accesses that topology object here:&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.16.0/src/libmongoc/src/mongoc/mongoc-client.c/#L1127&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/blob/1.16.0/src/libmongoc/src/mongoc/mongoc-client.c/#L1127&lt;/a&gt;&lt;br/&gt;
(Testing with ASAN revelealed this through a use-after-free).&lt;/p&gt;

&lt;p&gt;It technically seems ok to call &lt;tt&gt;mongoc_client_destroy&lt;/tt&gt; on a client prior to the pool being destroyed, but we already have explicit documentation about handling multi-threaded clients. The &lt;a href=&quot;http://mongoc.org/libmongoc/current/lifecycle.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Object Lifecycle&lt;/a&gt; page says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A program that uses libmongoc from multiple threads should create a mongoc_client_pool_t with mongoc_client_pool_new(). Each thread acquires a mongoc_client_t from the pool with mongoc_client_pool_pop() and returns it with mongoc_client_pool_push() when the thread is finished using it. To destroy the pool, first return all clients, then call mongoc_client_pool_destroy().&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;So I think we should reiterate that documentation in the relevant pool/client functions.&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|hurzmn:</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>