<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:01:05 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-42658] secondary don&apos;t refresh  its routing table when transition to primary.</title>
                <link>https://jira.mongodb.org/browse/SERVER-42658</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Recently, we get a strange phenomenon that all data of a sharding table are in the primary shard. After a period of research, i think i get a bug.&lt;br/&gt;
&#160;&lt;br/&gt;
There are 2 key problems here:&lt;br/&gt;
for mongos&apos;s CatalogCache&#65292;if the databaseInfoEntry already exists, it wouldn&#8217;t refresh a new table&apos;s metadata. And it will route to primary shard in CatalogCache::getCollectionRoutingInfo .Normally, that won&apos;t be a problem because the mongod will check the shardVersion of the opreation. But in the following scenario, there&apos;s a problem.&lt;br/&gt;
for mongod, secondary don&apos;t refresh its routing table &lt;b&gt;when transition to primary&lt;/b&gt;. And all tables are unshard in the new primary&apos;s shardingSate. so the operation of the above scenario can be executed, and at last some data may get a wrong shard for the sharded cluster.&lt;/p&gt;</description>
                <environment></environment>
        <key id="885829">SERVER-42658</key>
            <summary>secondary don&apos;t refresh  its routing table when transition to primary.</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="3">Duplicate</resolution>
                                        <assignee username="backlog-server-sharding">[DO NOT USE] Backlog - Sharding Team</assignee>
                                    <reporter username="lpc">FirstName lipengchong</reporter>
                        <labels>
                            <label>pull-request</label>
                    </labels>
                <created>Wed, 7 Aug 2019 03:20:36 +0000</created>
                <updated>Tue, 6 Dec 2022 02:51:26 +0000</updated>
                            <resolved>Tue, 13 Aug 2019 11:21:19 +0000</resolved>
                                    <version>3.4.22</version>
                    <version>3.6.12</version>
                    <version>4.0.10</version>
                                                    <component>Sharding</component>
                                        <votes>1</votes>
                                    <watches>10</watches>
                                                                                                                <comments>
                            <comment id="2369879" author="lpc" created="Wed, 14 Aug 2019 03:46:21 +0000"  >&lt;p&gt;hi&#160;&lt;a href=&quot;#Kaloian Manassiev&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Kaloian Manassiev&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;I think the problem of &quot;I don&apos;t know what&apos;s the state of this collection&quot; and &quot;The collection is unsharded&quot; is for mongos . But in my phenomenon , I think the main problem is&#160; mongod, mongod should refresh the routing tables when transition to primary. &lt;/p&gt;

&lt;p&gt;So maybe it is a different problem with the &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32198&quot; title=&quot;Missing collection metadata on the shard implies both UNSHARDED and &amp;quot;metadata not loaded yet&amp;quot;&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32198&quot;&gt;&lt;del&gt;SERVER-32198&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2368316" author="kaloian.manassiev" created="Tue, 13 Aug 2019 11:21:06 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=lpc&quot; class=&quot;user-hover&quot; rel=&quot;lpc&quot;&gt;lpc&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for the detailed description and repro steps. What you have experienced is caused by the fact that currently we have no way to differentiate between &quot;I don&apos;t know what&apos;s the state of this collection&quot; and &quot;The collection is unsharded&quot; and we are already tracking it by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32198&quot; title=&quot;Missing collection metadata on the shard implies both UNSHARDED and &amp;quot;metadata not loaded yet&amp;quot;&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32198&quot;&gt;&lt;del&gt;SERVER-32198&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please follow &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32198&quot; title=&quot;Missing collection metadata on the shard implies both UNSHARDED and &amp;quot;metadata not loaded yet&amp;quot;&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32198&quot;&gt;&lt;del&gt;SERVER-32198&lt;/del&gt;&lt;/a&gt; for the changes we are making in order to differentiate these states.&lt;/p&gt;

&lt;p&gt;Best regards,&lt;br/&gt;
-Kal.&lt;/p&gt;</comment>
                            <comment id="2363967" author="lpc" created="Fri, 9 Aug 2019 07:15:05 +0000"  >&lt;p&gt;I have attached a patch for resolve this problem. it&apos;s based on v34, other versions are similar it.&lt;/p&gt;</comment>
                            <comment id="2361769" author="daniel.hatcher" created="Wed, 7 Aug 2019 19:00:41 +0000"  >&lt;p&gt;Thanks for the report and the steps to reproduce. I can confirm that if I follow your scenario I end up in a state where both &lt;tt&gt;mongos&lt;/tt&gt; nodes only return some of the information found on the primary shard for the collection. I&apos;ll forward it along to our sharding team to take a further look.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="469026">SERVER-32198</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="226703" name="patch_3_4.diff" size="2540" author="lpc" created="Fri, 9 Aug 2019 07:12:24 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25141"><![CDATA[Sharding]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 7 Aug 2019 19:00:41 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 26 weeks, 1 day 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>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 26 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>backlog-server-sharding</customfieldvalue>
            <customfieldvalue>daniel.hatcher@mongodb.com</customfieldvalue>
            <customfieldvalue>lpc</customfieldvalue>
            <customfieldvalue>kaloian.manassiev@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hvj94f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hv86o7:</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_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;A Sharded Cluster with 2 replset shards (shard A and shard B), 2 mongos (a and b).&lt;br/&gt;
&lt;b&gt;1&#12289;in mongos a&lt;/b&gt;&lt;br/&gt;
mongos&amp;gt; sh.enableSharding(&quot;test&quot;)&lt;/p&gt;
{ &quot;ok&quot; : 1 }
&lt;p&gt;mongos&amp;gt; sh.shardCollection(&quot;test.table1&quot;,{_id:&quot;hashed&quot;})&lt;/p&gt;
{ &quot;collectionsharded&quot; : &quot;test.table1&quot;, &quot;ok&quot; : 1 }
&lt;p&gt;&#160;&lt;br/&gt;
&lt;b&gt;2&#12289;in mongos b&lt;/b&gt;&lt;br/&gt;
mongos&amp;gt; db.adminCommand({getShardVersion:&quot;test.table1&quot;})&lt;/p&gt;
{
&quot;version&quot; : Timestamp(2, 5),
&quot;versionEpoch&quot; : ObjectId(&quot;5d4a40b60a833e0eef3082f5&quot;),
&quot;ok&quot; : 1
}
&lt;p&gt;&#160;&lt;br/&gt;
&lt;b&gt;3&#12289;in mongos a&lt;/b&gt;&lt;br/&gt;
sh.shardCollection(&quot;test.table2&quot;,{_id:&quot;hashed&quot;})&lt;br/&gt;
&lt;b&gt;4&#12289;in mongos b&lt;/b&gt;&lt;br/&gt;
mongos&amp;gt; db.adminCommand({getShardVersion:&quot;test.table2&quot;})&lt;/p&gt;
{
&quot;code&quot; : 118,
&quot;ok&quot; : 0,
&quot;errmsg&quot; : &quot;Collection test.table2 is not sharded.&quot;
}
&lt;p&gt;&#160;&lt;br/&gt;
5&#12289;&lt;b&gt;stepdown the primary shard of &apos;test&apos; databse&lt;/b&gt;&#65292;and check the new priamry shardingState.&lt;br/&gt;
&#160;&lt;br/&gt;
pmongo186:PRIMARY&amp;gt; db.adminCommand({shardingState:1})&lt;br/&gt;
{&lt;br/&gt;
&quot;enabled&quot; : true,&lt;br/&gt;
&quot;configServer&quot; : &quot;cfg/xxxxxxxx&quot;,&lt;br/&gt;
&quot;shardName&quot; : &quot;pmongo186&quot;,&lt;br/&gt;
&quot;clusterId&quot; : ObjectId(&quot;5c5166d655a6f24da8dd7418&quot;),&lt;br/&gt;
&quot;versions&quot; : &lt;/p&gt;
{
&quot;test.system.indexes&quot; : Timestamp(0, 0),
&quot;test.table1&quot; : Timestamp(0, 0),
&quot;test.table2&quot; : Timestamp(0, 0),
&quot;local.replset.minvalid&quot; : Timestamp(0, 0),
&quot;local.replset.election&quot; : Timestamp(0, 0),
&quot;local.me&quot; : Timestamp(0, 0),
&quot;local.startup_log&quot; : Timestamp(0, 0),
&quot;admin.system.version&quot; : Timestamp(0, 0),
&quot;local.oplog.rs&quot; : Timestamp(0, 0),
&quot;admin.system.roles&quot; : Timestamp(0, 0),
&quot;admin.system.users&quot; : Timestamp(0, 0),
&quot;local.system.replset&quot; : Timestamp(0, 0),
}
&lt;p&gt;,&lt;br/&gt;
&quot;ok&quot; : 1&lt;br/&gt;
}&lt;br/&gt;
pmongo186:PRIMARY&amp;gt;&lt;br/&gt;
pmongo186:PRIMARY&amp;gt; db.adminCommand({getShardVersion:&quot;test.table2&quot;})&lt;/p&gt;
{
&quot;configServer&quot; : &quot;cfg/xxxxxxxx&quot;,
&quot;inShardedMode&quot; : false,
&quot;mine&quot; : Timestamp(0, 0),
&quot;global&quot; : Timestamp(0, 0),
&quot;ok&quot; : 1
}
&lt;p&gt;&#160;&lt;br/&gt;
and from now on , all insert of test.table2 with mongos b will go to the primary shard. we flushRouterConfig of mongos b , we can&#8217;t get all data just inserted &#12290;&lt;br/&gt;
&#160;&lt;br/&gt;
&lt;b&gt;6&#12289; in mongos b&lt;/b&gt;&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:1})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:2})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:3})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:4})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:5})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:6})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:7})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt; db.table2.insert({_id:8})&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
mongos&amp;gt;&lt;br/&gt;
mongos&amp;gt; db.adminCommand({flushRouterConfig:1})&lt;/p&gt;
{ &quot;flushed&quot; : true, &quot;ok&quot; : 1 }
&lt;p&gt;mongos&amp;gt; db.table2.find()&lt;/p&gt;
{ &quot;_id&quot; : 3 }
{ &quot;_id&quot; : 6 }
{ &quot;_id&quot; : 8 }
&lt;p&gt;&#160;&lt;br/&gt;
&lt;b&gt;7&#12289;in mongos a&lt;/b&gt;, we can&apos;t get data just insert&lt;br/&gt;
mongos&amp;gt; use test&lt;br/&gt;
switched to db test&lt;br/&gt;
mongos&amp;gt; db.table2.find()&lt;/p&gt;
{ &quot;_id&quot; : 3 }
{ &quot;_id&quot; : 6 }
{ &quot;_id&quot; : 8 }</customfieldvalue>

                        </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|hvivdr:</customfieldvalue>

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