<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:55:07 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-40483] Changing the shard key could lead to DuplicateKeyError on _id with orphan documents</title>
                <link>https://jira.mongodb.org/browse/SERVER-40483</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If we change a document&apos;s shard key such that the document will have to change shards, we could end up with a duplicate key error on _id due to an orphaned version of that document existing on that shard. Other legitimate DuplicateKeyErrors could occur (for example, if there&apos;s a unique index on the shard key), in which case we&apos;ll throw an ordinary DuplicateKeyError. This ticket only addresses _id conflicts.&lt;/p&gt;

&lt;p&gt;Consider the following scenario:&lt;br/&gt;
1) A document x is migrated from shard A to shard B. Suppose the RangeDeleter does not run yet, and the orphaned document x remains on shard A.&lt;br/&gt;
2) An update is issued to document x (residing on shard B) such that it requires moving that document back to shard A. The update operation is converted into a delete from shard B and an insert into shard A.&lt;br/&gt;
3) The insert operation into shard A fails with a duplicate key error on _id, because the orphaned version of x still exists on shard A.&lt;/p&gt;

&lt;p&gt;We should make sure this case leads to an error message that&apos;s more meaningful to the user than DuplicateKeyError (something indicated it&apos;s related to orphaned documents), and perhaps with a link to documentation.&lt;/p&gt;</description>
                <environment></environment>
        <key id="729839">SERVER-40483</key>
            <summary>Changing the shard key could lead to DuplicateKeyError on _id with orphan documents</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="janna.golden@mongodb.com">Janna Golden</assignee>
                                    <reporter username="matthew.saltz@mongodb.com">Matthew Saltz</reporter>
                        <labels>
                    </labels>
                <created>Thu, 4 Apr 2019 19:18:55 +0000</created>
                <updated>Sun, 29 Oct 2023 22:22:18 +0000</updated>
                            <resolved>Thu, 18 Apr 2019 13:49:08 +0000</resolved>
                                                    <fixVersion>4.1.11</fixVersion>
                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="2216548" author="xgen-internal-githook" created="Wed, 17 Apr 2019 15:13:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;golden.janna@gmail.com&apos;, &apos;name&apos;: &apos;jannaerin&apos;, &apos;username&apos;: &apos;jannaerin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40483&quot; title=&quot;Changing the shard key could lead to DuplicateKeyError on _id with orphan documents&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40483&quot;&gt;&lt;del&gt;SERVER-40483&lt;/del&gt;&lt;/a&gt; Return more informative error when changing the doc shard key caues DuplicateKey error on _id&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/d7fb557f6fc6d486fa7107a8f64342caf552eeb4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/d7fb557f6fc6d486fa7107a8f64342caf552eeb4&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2206577" author="matthew.saltz" created="Tue, 9 Apr 2019 14:53:57 +0000"  >&lt;p&gt;Updated to specify that the ticket only focuses on _id index uniqueness conflicts&lt;/p&gt;</comment>
                            <comment id="2206540" author="schwerin" created="Tue, 9 Apr 2019 14:40:19 +0000"  >&lt;p&gt;Per offline discussion, I think this ticket is intended to focus only on _id index uniqueness conflicts. &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=matthew.saltz&quot; class=&quot;user-hover&quot; rel=&quot;matthew.saltz&quot;&gt;matthew.saltz&lt;/a&gt; has agreed to review the description and update it if appropriate.&lt;/p&gt;</comment>
                            <comment id="2205941" author="matthew.saltz" created="Mon, 8 Apr 2019 22:08:15 +0000"  >&lt;p&gt;As a historical note for the ticket, since I think this is the situation you&apos;re already aware of and referring to: It&apos;s possible, if the client for some reason does not enforce global uniqueness of _id across shards, that we could end up with this error occurring even for non-orphaned documents.&lt;/p&gt;

&lt;p&gt;I think we could know when it&apos;s caused by an orphaned document by checking the routing table whenever DuplicateKeyError is thrown to check whether the document was owned by this shard, but I don&apos;t think it&apos;s completely straightforward (mostly for code arrangement reasons and where different state is tracked) . Based on our discussion the other day, I thought we concluded that it was okay to end up reporting an error in this situation given that generally speaking we assume _id is globally unique, even though it&apos;s not enforced. &lt;/p&gt;

&lt;p&gt;We can make the error message say &quot;either related to orphaned documents or due to _id not being globally unique&quot; - that may be clearer. What do you think?&lt;/p&gt;</comment>
                            <comment id="2204380" author="schwerin" created="Sat, 6 Apr 2019 22:08:26 +0000"  >&lt;p&gt;Can we definitively know when it&#8217;s caused by orphans?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="744806">SERVER-40815</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.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_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sat, 6 Apr 2019 22:08:26 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 43 weeks 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-1163</customfieldvalue>
                        </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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 43 weeks 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>schwerin@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>janna.golden@mongodb.com</customfieldvalue>
            <customfieldvalue>matthew.saltz@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hut19j:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|huikfz:</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="2864">Sharding 2019-04-22</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|husniv:</customfieldvalue>

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