<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:25:58 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-11509] movePrimary should error when database is not drained</title>
                <link>https://jira.mongodb.org/browse/SERVER-11509</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;We had very confusing behavior where a collection was reporting one set of documents some of the time, and other results at other times.  We deduced (and verified) that this was because non-sharded collections (in a sharded environment) were being accessed on two different shards.  What appears to have happened is that at least one of our mongos did not get the movePrimary message, meaning it still believed (and interacted with) data on the old shard.&lt;/p&gt;

&lt;p&gt;Now, in our situation, we admissibly committed a faux pas: we ran movePrimary while a shard was draining.  I realize that the web docs explicitly state not to do this, but it happened.&lt;/p&gt;

&lt;p&gt;It seems that movePrimary either:&lt;/p&gt;

&lt;p&gt;A) Doesn&apos;t move collections atomically&lt;br/&gt;
B) Isn&apos;t very forceful about having mongos update their routing tables&lt;br/&gt;
C) Doesn&apos;t play nicely at all with the balancer when a shard is draining&lt;/p&gt;

&lt;p&gt;Or something else I suppose.  Either way, it seems reasonable that movePrimary will raise an error (rather than creating inconsistencies) if it truly needs to be ran only when all chunks are moved off of a shard.  If it does not actually need that, then there clearly is a bug somewhere that is leading to very confusing and inconsistent errors.&lt;/p&gt;</description>
                <environment>Ubuntu servers</environment>
        <key id="96623">SERVER-11509</key>
            <summary>movePrimary should error when database is not drained</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="9">Done</resolution>
                                        <assignee username="backlog-server-sharding">[DO NOT USE] Backlog - Sharding Team</assignee>
                                    <reporter username="shadowman131">Walt Woods</reporter>
                        <labels>
                            <label>PM-1017</label>
                    </labels>
                <created>Thu, 31 Oct 2013 19:31:39 +0000</created>
                <updated>Tue, 6 Dec 2022 05:15:16 +0000</updated>
                            <resolved>Tue, 12 Nov 2019 18:50:00 +0000</resolved>
                                    <version>2.4.6</version>
                                                    <component>Sharding</component>
                                        <votes>1</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="2537150" author="esha.maharishi@10gen.com" created="Tue, 12 Nov 2019 18:50:00 +0000"  >&lt;p&gt;Closing this as Gone Away since it was fixed by PM-1051.&lt;/p&gt;</comment>
                            <comment id="2099584" author="salty-horse" created="Mon, 24 Dec 2018 09:54:12 +0000"  >&lt;p&gt;Still relevant for 3.6+.&lt;/p&gt;</comment>
                            <comment id="683979" author="greg_10gen" created="Thu, 7 Aug 2014 16:24:44 +0000"  >&lt;p&gt;&amp;gt; If what you say is necessarily the case, the &quot;movePrimary&quot; command should return an error when trying to movePrimary from a shard that still has chunks remaining, rather than silently cause inconsistency.&lt;/p&gt;

&lt;p&gt;Reading the history here again, I&apos;m not sure this is the problem you ran into, as you mention above:&lt;/p&gt;

&lt;p&gt;&amp;gt; non-sharded collections (in a sharded environment) were being accessed on two different shards&lt;/p&gt;

&lt;p&gt;MovePrimary cannot atomically move unsharded collections - the only way to atomically move collections between shards is to shard the collection and move chunk-by-chunk.  MovePrimary should not move chunks from sharded collections, and from your description it seems this is not what happened.  After a movePrimary, because unsharded collections are not versioned, there is no automated way for mongos to learn of the move aside from a manual flushRouterConfig.&lt;/p&gt;

&lt;p&gt;This is definitely an area we&apos;re trying to improve, but requires some serious work - see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-939&quot; title=&quot;Ability to distribute collections in a single db&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-939&quot;&gt;SERVER-939&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="453206" author="shadowman131" created="Thu, 7 Nov 2013 21:05:13 +0000"  >&lt;p&gt;Thank you&lt;/p&gt;</comment>
                            <comment id="453183" author="david.storch" created="Thu, 7 Nov 2013 20:43:04 +0000"  >&lt;p&gt;Hi Walt, yes, perhaps we should change the error behavior of move primary so that it prevents you from using it when it could be unsafe. I&apos;ll update the title to reflect that this is about specifically about error behavior and re-open for triage.&lt;/p&gt;</comment>
                            <comment id="453173" author="shadowman131" created="Thu, 7 Nov 2013 20:28:56 +0000"  >&lt;p&gt;Hi David, that&apos;s not really sufficient, as I mention in the bug report.&lt;/p&gt;

&lt;p&gt;If what you say is necessarily the case, the &quot;movePrimary&quot; command should return an error when trying to movePrimary from a shard that still has chunks remaining, rather than silently cause inconsistency.&lt;/p&gt;</comment>
                            <comment id="453132" author="david.storch" created="Thu, 7 Nov 2013 19:26:57 +0000"  >&lt;p&gt;Hi Walt,&lt;/p&gt;

&lt;p&gt;As you have noticed in the &lt;a href=&quot;http://docs.mongodb.org/manual/reference/command/movePrimary/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;documentation&lt;/a&gt;, the movePrimary command should only be used 1) after all sharded collections have been drained from the database, or 2) the database does not contain any collections with data. I&apos;m going to mark this ticket &quot;Works as Designed&quot;, as the movePrimary command is only designed for use in these limited circumstances.&lt;/p&gt;

&lt;p&gt;Using movePrimary in other circumstances is neither atomic nor isolated and can lead to data inconsistency problems such as the one that you experienced. Moving unsharded collections (and, consequently, moving databases which contain unsharded collections) is difficult to do safely because MongoDB does not track metadata for such collections.&lt;/p&gt;</comment>
                            <comment id="451648" author="shadowman131" created="Tue, 5 Nov 2013 17:29:29 +0000"  >&lt;p&gt;We didn&apos;t have too much time, but were unable to reproduce this via a simple script.  Definitely still a concerning issue though.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="10661">SERVER-939</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="60737">SERVER-8059</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.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>Thu, 7 Nov 2013 17:10:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 13 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<a href='https://jira.mongodb.org/browse/SERVER-939'>SERVER-939</a>]]></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, 13 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </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>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>esha.maharishi@mongodb.com</customfieldvalue>
            <customfieldvalue>greg_10gen</customfieldvalue>
            <customfieldvalue>salty-horse</customfieldvalue>
            <customfieldvalue>shadowman131</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrm8m7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr7pfr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7284</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="2581">Sharding 2018-11-19</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Unsure.  We&apos;re spending a little time trying to make a reproduction script, but essentially something along the lines of:&lt;/p&gt;

&lt;p&gt;1. Have multiple mongos running (we have 12 or so) and several populated shards (we have 8), with some collections in a database sharded and some collections unsharded.&lt;/p&gt;

&lt;p&gt;2. Start draining the shard that is the current primary for the database.&lt;/p&gt;

&lt;p&gt;3. While it is draining, run movePrimary to another shard.&lt;/p&gt;

&lt;p&gt;4. Query each mongos separately, looking for inconsistent results.&lt;/p&gt;</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|hri2qn:</customfieldvalue>

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