<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:15:34 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-2552] Race condition causes assert failure after secondary removed from replica set</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-2552</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;I made a mistake implementing &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-562&quot; title=&quot;cluster should send newly-run ismasters through SDAM machinery&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-562&quot;&gt;&lt;del&gt;CDRIVER-562&lt;/del&gt;&lt;/a&gt;, which can result in an assert failure when connected to a replica set. I&apos;m not certain what race condition, or perhaps replica set misconfiguration, can cause it, but I can describe the sequence of events and a fix anyway.&lt;/p&gt;

&lt;p&gt;1. Driver discovers a replica set with a primary A and at least one secondary B&lt;br/&gt;
2. Driver opens a new connection to A (either because of a prior disconnect in single mode, or while expanding the pool in pooled mode)&lt;br/&gt;
3. Driver handshakes the new connection by calling isMaster on A&lt;br/&gt;
4. A, for some reason, suddenly does not include B in its host list, perhaps because B was removed from the configuration, or because of some persistent misconfiguration&lt;br/&gt;
5. The driver marks B as &quot;retired&quot; so it can be removed from the topology description soon (this is my implementation of &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#updatersfromprimary&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;updateRSFromPrimary&lt;/a&gt; in the Server Discovery and Monitoring Spec, with a simplification to avoid a crash, &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-789&quot; title=&quot;segfault in test_rs_seeds_connect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-789&quot;&gt;&lt;del&gt;CDRIVER-789&lt;/del&gt;&lt;/a&gt;).&lt;br/&gt;
6. The driver&apos;s connection to B is disconnected somehow.&lt;br/&gt;
7. During the next scan, in mongoc_topology_scanner_node_setup, the driver sees that B is disconnected, and before it begins reconnecting, it asserts that B is not marked &quot;retired&quot;&lt;/p&gt;

&lt;p&gt;The point of the assert was to validate my understanding of the &quot;retired&quot; field. I thought it was always cleared after a scan, I didn&apos;t realize the side effect of &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-562&quot; title=&quot;cluster should send newly-run ismasters through SDAM machinery&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-562&quot;&gt;&lt;del&gt;CDRIVER-562&lt;/del&gt;&lt;/a&gt;, which I implemented recently, which allowed &quot;retired&quot; to be set before the next scan began.&lt;/p&gt;

&lt;p&gt;The solution is probably, at the beginning of each scan, to remove any nodes that have been retired by handshakes. The assert can remain in place.&lt;/p&gt;

&lt;p&gt;In addition, there had been a bug not only when&lt;br/&gt;
_mongoc_topology_update_from_handshake retires a node, but also when it adds&lt;br/&gt;
one. The newly-added node has a mongoc_async_cmd_t created for it, even though&lt;br/&gt;
it&apos;s outside the scanner loop. Therefore in mongoc_topology_scanner_start the&lt;br/&gt;
assert (!node-cmd) fails. This was fixed as a side effect of &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1972&quot; title=&quot;Support IPv6 only hostnames&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1972&quot;&gt;&lt;del&gt;CDRIVER-1972&lt;/del&gt;&lt;/a&gt; during 1.10 development.&lt;/p&gt;

&lt;p&gt;This fix will not be backported.&lt;/p&gt;</description>
                <environment></environment>
        <key id="512093">CDRIVER-2552</key>
            <summary>Race condition causes assert failure after secondary removed from replica set</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="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="jesse@mongodb.com">A. Jesse Jiryu Davis</reporter>
                        <labels>
                    </labels>
                <created>Thu, 15 Mar 2018 21:17:27 +0000</created>
                <updated>Sat, 28 Oct 2023 11:30:02 +0000</updated>
                            <resolved>Thu, 12 Apr 2018 02:27:32 +0000</resolved>
                                    <version>1.5.0</version>
                                    <fixVersion>1.10.0</fixVersion>
                                    <component>libmongoc</component>
                    <component>replset</component>
                                        <votes>1</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1844127" author="xgen-internal-githook" created="Sat, 24 Mar 2018 02:31:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt; don&apos;t reconcile scanner nodes from handshake&lt;/p&gt;

&lt;p&gt;Simpler solution: don&apos;t risk retiring a scanner node or creating an async_cmd_t&lt;br/&gt;
while processing a handshake at all. Wait until we&apos;re about to scan before&lt;br/&gt;
reconciling scanner nodes with the updated topology description.&lt;/p&gt;

&lt;p&gt;Also factor the steps required to start a scan into a new function,&lt;br/&gt;
mongoc_topology_scan_once.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/1e25a1d72e69c91b02cbc85731624b957bff9bc8&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/1e25a1d72e69c91b02cbc85731624b957bff9bc8&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1844126" author="xgen-internal-githook" created="Sat, 24 Mar 2018 02:31:45 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt; test adding node from handshake&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/ef895faadfdc4c6a447ccf0a94b26541a91f8975&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/ef895faadfdc4c6a447ccf0a94b26541a91f8975&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1840913" author="xgen-internal-githook" created="Wed, 21 Mar 2018 16:31:03 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt; rare assert failure during RS reconfig, r1.6&lt;br/&gt;
Branch: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt;-on-r1.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/a101fd1d89e76118955079bb75097180536f8fa5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/a101fd1d89e76118955079bb75097180536f8fa5&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1840912" author="xgen-internal-githook" created="Wed, 21 Mar 2018 16:31:02 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt; test add secondary in handshake, r1.6&lt;br/&gt;
Branch: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt;-on-r1.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/e97a567555eddf96ea7cb9ff9e0b09ccfa692036&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/e97a567555eddf96ea7cb9ff9e0b09ccfa692036&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1840911" author="xgen-internal-githook" created="Wed, 21 Mar 2018 16:31:00 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt; test del secondary in handshake, r1.6&lt;br/&gt;
Branch: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt;-on-r1.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/14b1a2065806cf6dac3cfb65c231da27f464464c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/14b1a2065806cf6dac3cfb65c231da27f464464c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838631" author="xgen-internal-githook" created="Mon, 19 Mar 2018 18:20:06 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2552&quot; title=&quot;Race condition causes assert failure after secondary removed from replica set&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2552&quot;&gt;&lt;del&gt;CDRIVER-2552&lt;/del&gt;&lt;/a&gt; rare assert failure during RS reconfig&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/e1b2861946fcb8dd278a0d6aeb596da965c4698b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/e1b2861946fcb8dd278a0d6aeb596da965c4698b&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                    <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[500A000000ZsvPSIAZ]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <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|htk47z:</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>