<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:17:03 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-3068] Topology scanner stuck when changing standalone server to replica set</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-3068</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;I am using the C driver (via mongo-cxx-driver) in pooled mode.&lt;/p&gt;

&lt;p&gt;First, I create a pool using the URL &lt;tt&gt;mongodb://localhost:27017&lt;/tt&gt;. The server is a standalone MongoDB 4.0.3 server.&lt;/p&gt;

&lt;p&gt;Then, I destroy that pool and create a new pool using the URL mongodb://localhost:27017/?replicaset=rep. Afterwards, I stop the MongoDB server and start it again as a single replica set (with replica set name &quot;rep&quot;). I can successfully connect to the server using the Mongo shell (and e.g. call &quot;rs.initiate()&quot;).&lt;/p&gt;

&lt;p&gt;However, I cannot connect to the replica set using clients from the new pool in my program. Using APM&#160; callbacks, it seems like the topology scanner does not get notified of the new configuration:&lt;/p&gt;

&lt;p&gt;&lt;cite&gt;mongodb://localhost:27017: topology changed (5ca4c4969a183ffe80003b21) Single -&amp;gt; Single&lt;/cite&gt;&lt;br/&gt;
?? previous servers:??&lt;br/&gt;
?? Standalone localhost:27017 (master)??&lt;br/&gt;
?? new servers:??&lt;br/&gt;
?? Standalone localhost:27017 (master)??&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017: server changed (5ca4c4969a183ffe80003b21): localhost:27017 -&amp;gt; localhost:27017&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017: topology changed (5ca4c4969a183ffe80003b21) Single -&amp;gt; Single&lt;/cite&gt;&lt;br/&gt;
?? previous servers:??&lt;br/&gt;
?? Standalone localhost:27017 (master)??&lt;br/&gt;
?? new servers: Standalone localhost:27017 (master)??&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017: topology closed (5ca4c4969a183ffe80003b21)&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017/?replicaset=rep: topology opening (5ca4c4d99a183ffe80003b23)&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017/?replicaset=rep: topology changed (5ca4c4d99a183ffe80003b23) Unknown -&amp;gt; ReplicaSetNoPrimary&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017/?replicaset=rep: server opening (5ca4c4d99a183ffe80003b23): localhost:27017&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017/?replicaset=rep: server changed (5ca4c4d99a183ffe80003b23): localhost:27017 -&amp;gt; localhost:27017&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017/?replicaset=rep: server closed (5ca4c4d99a183ffe80003b23): localhost:27017&lt;/cite&gt;&lt;br/&gt;
&lt;cite&gt;mongodb://localhost:27017/?replicaset=rep: topology changed (5ca4c4d99a183ffe80003b23) ReplicaSetNoPrimary -&amp;gt; ReplicaSetNoPrimary&lt;/cite&gt;&lt;/p&gt;

&lt;p&gt;I am stuck as of now. The actual code is part of a larger code-base. If there is nothing else I could try, I could create a minimal working program which hopefully reproduces this.&lt;/p&gt;

&lt;p&gt;Thanks in advance.&lt;/p&gt;</description>
                <environment></environment>
        <key id="728972">CDRIVER-3068</key>
            <summary>Topology scanner stuck when changing standalone server to replica set</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="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="saszel">Sascha Zelzer</reporter>
                        <labels>
                    </labels>
                <created>Wed, 3 Apr 2019 14:52:21 +0000</created>
                <updated>Fri, 27 Oct 2023 13:14:12 +0000</updated>
                            <resolved>Mon, 3 Jun 2019 14:44:43 +0000</resolved>
                                    <version>1.14.0</version>
                                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="2282354" author="saszel" created="Thu, 13 Jun 2019 06:32:45 +0000"  >&lt;p&gt;Thanks a lot for your analysis and the creation of the two follow-up tickets.&lt;/p&gt;</comment>
                            <comment id="2228977" author="jmikola@gmail.com" created="Tue, 30 Apr 2019 12:53:45 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=saszel&quot; class=&quot;user-hover&quot; rel=&quot;saszel&quot;&gt;saszel&lt;/a&gt;: Based on the list of steps you shared to reproduce the problem, I believe the topology scanner is performing as designed.&lt;/p&gt;

&lt;p&gt;The scanner initially disregards &lt;tt&gt;localhost:27017&lt;/tt&gt; because it is not a member of the &quot;rep&quot; replica set, which leaves the topology in the ReplicaSetNoPrimary state with no candidate servers (see: &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#topologytype-table&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;transition table&lt;/a&gt; in the SDAM specification). Any monitoring intervals from that point on are no-ops since there are no remaining servers in the topology. Although &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#other-topologytypes&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;SDAM: Other Topology Types&lt;/a&gt; notes that clients (i.e. drivers) should emit a warning if the last candidate server would be removed from a topology, I don&apos;t believe libmongoc does so. I have opened &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3107&quot; title=&quot;Warn when removing the last server from a topology&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3107&quot;&gt;&lt;del&gt;CDRIVER-3107&lt;/del&gt;&lt;/a&gt; to track that improvement.&lt;/p&gt;

&lt;p&gt;The correct course of action would be to convert the MongoDB deployment to a replica set &lt;em&gt;before&lt;/em&gt; modifying the application. So long as the new replica set primary was also accessible via &lt;tt&gt;localhost:27017&lt;/tt&gt;, the application would still be able to connect to it and execute read/write operations as if it were a standalone. Once the replica set was configured, you could then reconfigure the driver&apos;s URI by adding the &quot;replicaSet&quot; option and optionally adding more hosts to the connection string (per replica set &lt;a href=&quot;https://docs.mongodb.com/manual/reference/connection-string/#examples&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;connection string examples&lt;/a&gt;) and finally restart the application.&lt;/p&gt;

&lt;p&gt;I realize this was not explicitly stated in the MongoDB manual&apos;s tutorial for &lt;a href=&quot;https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Converting a standalone to a replica set&lt;/a&gt;. I&apos;ve also opened &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-12661&quot; title=&quot;[Server] Advise users when to reconfigure and restart applications after topology upgrades&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-12661&quot;&gt;&lt;del&gt;DOCS-12661&lt;/del&gt;&lt;/a&gt; to request an improvement to that document.&lt;/p&gt;</comment>
                            <comment id="2200608" author="saszel" created="Wed, 3 Apr 2019 15:26:53 +0000"  >&lt;p&gt;Creating two pools is actually not necessary. Here is a simplified list of steps to reproduce this:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Run a standalone MongoDB server&lt;/li&gt;
	&lt;li&gt;Create a pool using mongodb://localhost:27017/?replicaset=rep (as expected, clients cannot connect using that pool)&lt;/li&gt;
	&lt;li&gt;Stop the MongoDB server and start it again with the &lt;tt&gt;--replset rep&lt;/tt&gt; command line option (and initialize it)&lt;/li&gt;
	&lt;li&gt;Clients from the pool are still not able to connect and APM callbacks do not show any activity for the scanner&lt;/li&gt;
&lt;/ol&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="750681">DOCS-12661</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="750675">CDRIVER-3107</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|huifjr:</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>