<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:05:45 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>[SERVER-44352] What will be the behavior of mongos under this partial network partition</title>
                <link>https://jira.mongodb.org/browse/SERVER-44352</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Consider a shard cluster:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Has only one shard, but the shard has 3 replicas A, B, C&lt;/li&gt;
	&lt;li&gt;Has 3 mongos instances&lt;/li&gt;
	&lt;li&gt;mongos and mongod instance are running across 3 different data centers.&lt;/li&gt;
	&lt;li&gt;The primary node (A) of the replica set is in Data center 1&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;It will look like this:&lt;/p&gt;

&lt;p&gt;Data Center 1&#160; &#160; &#160; &#160; &#160; |&#160; &#160; &#160; &#160;Data Center 2&#160; &#160; &#160; &#160; &#160; &#160; &#160;|&#160; &#160; &#160;Data Center 3&lt;/p&gt;

&lt;p&gt;mongos&#160; 1&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; |&#160; &#160; &#160; &#160;mongos 2&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; |&#160; &#160; &#160;mongos 3&lt;/p&gt;

&lt;p&gt;Primary node (A)&#160; &#160; |&#160; &#160; &#160; &#160;secondary node (B)&#160; &#160;|&#160; &#160; &#160;secondary node (C)&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Now, suppose there is a network partition between Data center 1 and 2, A and B cannot see each other, but C can see both. In this case, if I understand correctly, B will try to elect itself to be the primary, but it will fail because A can still see the majority of the replica sets (A and C), and C can still see A.&lt;/p&gt;

&lt;p&gt;In this case, if a client talks to the mongos 2 which is running in DataCenter 2, will all the read and write operation for this client fail because the network between Data Center 1 and Data Center 2 is broken, so it cannot reach the primary node?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="987150">SERVER-44352</key>
            <summary>What will be the behavior of mongos under this partial network partition</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</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="9">Done</resolution>
                                        <assignee username="carl.champain@mongodb.com">Carl Champain</assignee>
                                    <reporter username="wangzicong@bytedance.com">Atwood Wang</reporter>
                        <labels>
                    </labels>
                <created>Fri, 1 Nov 2019 08:51:42 +0000</created>
                <updated>Fri, 8 Nov 2019 22:05:31 +0000</updated>
                            <resolved>Fri, 8 Nov 2019 22:05:31 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="2526266" author="carl.champain" created="Fri, 8 Nov 2019 22:01:48 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=wangzicong%40bytedance.com&quot; class=&quot;user-hover&quot; rel=&quot;wangzicong@bytedance.com&quot;&gt;wangzicong@bytedance.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;In this case, if I understand correctly, B will try to elect itself to be the primary, but it will fail because A can still see the majority of the replica sets (A and C), and C can still see A.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In summary, B will run for election and will fail. A couple of reasons why:&lt;br/&gt;
 1. A won&apos;t respond&lt;br/&gt;
 2. C will notice that B doesn&apos;t have the latest applied ops from A, so C will vote no for B&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;In my previous understanding, I thought under a network partition case when A is the primary, B and C are secondaries, and the network between A and B is broken. I thought B will start an election but C will reject it since it can see A is an active primary. However, after seeing these lines of code, seems like C will reject the request only if it is an arbiter. If C is an normal data-bearing node, it will approve B&apos;s request.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To help you understand a bit more, please take a look at this &lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/db/repl/topology_coordinator.cpp#L2756&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;else if block of code&lt;/a&gt; which checks if B has staler data than C, this is the same section you pointed out but only a few lines up. B has stale data since it can&apos;t replicate the latest writes on A. Consequently, B has only one yes (itself) and loses.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;if a client talks to the mongos 2 which is running in DataCenter 2, will all the read and write operation for this client fail&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If a client talks to the mongos 2, then all writes should fail. However, if you add all mongos to the connection string at the application level, and if you add retry logic when they the client gets a no primaries found error, then the application can attempt to send the writes to another mongos.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Will this make B become a primary and result in C seeing two primaries, A and B?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;So in this situation, there can&apos;t be two primaries. However, in a different situation where this happens, there is a mechanism which ensures that the the old primary steps down. The field &lt;tt&gt;term&lt;/tt&gt; in &lt;tt&gt;rs.status()&lt;/tt&gt; is a counter indicating how many elections have occurred. So when the old primary goes back online, it will see that its value in &lt;tt&gt;term&lt;/tt&gt; is lower than the current value in the replica set and will step down.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;That said, the SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket does not appear to be a bug, I will now close it. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the &lt;a href=&quot;https://groups.google.com/group/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongodb-user group&lt;/a&gt; or on &lt;a href=&quot;https://stackoverflow.com/questions/tagged/mongodb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Stack Overflow with the &lt;tt&gt;mongodb&lt;/tt&gt; tag&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;br/&gt;
 Carl&lt;/p&gt;</comment>
                            <comment id="2517626" author="wangzicong@bytedance.com" created="Tue, 5 Nov 2019 08:32:58 +0000"  >&lt;p&gt;I found something else that I don&apos;t understand.&lt;/p&gt;

&lt;p&gt;In my previous understanding, I thought under a network partition case when A is the primary, B and C are secondaries, and the network between A and B is broken. I thought B will start an election but C will reject it since it can see A is an active primary. However, after seeing &lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/db/repl/topology_coordinator.cpp#L2770-L2776&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;these&lt;/a&gt; lines of code, seems like C will reject the request only if it is an arbiter. If C is an normal data-bearing node, it will approve B&apos;s request. Will this make B become a primary and result in C seeing two primaries, A and B?&lt;/p&gt;

&lt;p&gt;I am not sure if I am missing some key logic in this process, any help will be super appreciated.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 8 Nov 2019 22:01:48 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 13 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>carl.champain@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 13 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>wangzicong@bytedance.com</customfieldvalue>
            <customfieldvalue>carl.champain@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hw055r:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hvohw7:</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>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hvzrf3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>