<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:17: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-8320] Inserting with a compound shard key results in data on wrong shard</title>
                <link>https://jira.mongodb.org/browse/SERVER-8320</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;We are doing pre-production load/scale testing and have a sharded collection with the following configuraiton:&lt;/p&gt;

&lt;p&gt;db.createCollection(&apos;sitemedia&apos;);&lt;br/&gt;
db.sitemedia.ensureIndex( &lt;/p&gt;
{ &quot;user.id&quot;: 1, &quot;_id&quot; : 1 }
&lt;p&gt; );&lt;br/&gt;
sh.shardCollection(&quot;vsco_1.sitemedia&quot;,&lt;/p&gt;
{&quot;user.id&quot;:1,&quot;_id&quot;:1}
&lt;p&gt;);&lt;br/&gt;
db.sitemedia.ensureIndex( &lt;/p&gt;
{ &quot;user.id&quot;: 1, &quot;tags.slug&quot; : 1 }
&lt;p&gt; )&lt;br/&gt;
db.sitemedia.ensureIndex( &lt;/p&gt;
{ &quot;user.id&quot;: 1, &quot;capture_date&quot; : 1 }
&lt;p&gt; )&lt;br/&gt;
db.sitemedia.ensureIndex( &lt;/p&gt;
{ &quot;user.id&quot;: 1, &quot;upload_date&quot; : 1 }
&lt;p&gt; )&lt;/p&gt;


&lt;p&gt;After several hundred thousand inserts we end up with the following:&lt;/p&gt;

&lt;p&gt;mongos&amp;gt; sh.status()&lt;br/&gt;
&amp;#8212; Sharding Status &amp;#8212; &lt;br/&gt;
  sharding version: &lt;/p&gt;
{ &quot;_id&quot; : 1, &quot;version&quot; : 3 }
&lt;p&gt;  shards:&lt;/p&gt;
	{  &quot;_id&quot; : &quot;s0&quot;,  &quot;host&quot; : &quot;s0/x.x.x.x:27017,x.x.x.x:27017,x.x.x.x:27017&quot; }
	{  &quot;_id&quot; : &quot;s1&quot;,  &quot;host&quot; : &quot;s1/x.x.x.x:27017,x.x.x.x:27017,x.x.x.x:27017&quot; }
&lt;p&gt;  databases:&lt;/p&gt;
	{  &quot;_id&quot; : &quot;admin&quot;,  &quot;partitioned&quot; : false,  &quot;primary&quot; : &quot;config&quot; }
	{  &quot;_id&quot; : &quot;vsco_1&quot;,  &quot;partitioned&quot; : true,  &quot;primary&quot; : &quot;s1&quot; }
&lt;p&gt;		vsco_1.sitemedia chunks:&lt;br/&gt;
				s1	5&lt;br/&gt;
				s0	5&lt;br/&gt;
			{ &quot;user.id&quot; : &lt;/p&gt;
{ $minKey : 1 }
&lt;p&gt;, &quot;_id&quot; : &lt;/p&gt;
{ $minKey : 1 }
&lt;p&gt; } --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 1, &quot;_id&quot; : ObjectId(&quot;5100315283ce40cc3c000000&quot;) }
&lt;p&gt; on : s1 Timestamp(6000, 0) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 1, &quot;_id&quot; : ObjectId(&quot;5100315283ce40cc3c000000&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 21346, &quot;_id&quot; : ObjectId(&quot;50fdca5583ce40427d0000a1&quot;) }
&lt;p&gt; on : s0 Timestamp(6000, 1) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 21346, &quot;_id&quot; : ObjectId(&quot;50fdca5583ce40427d0000a1&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 21498, &quot;_id&quot; : ObjectId(&quot;50fdcd7783ce40cd7d0001f7&quot;) }
&lt;p&gt; on : s0 Timestamp(5000, 5) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 21498, &quot;_id&quot; : ObjectId(&quot;50fdcd7783ce40cd7d0001f7&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 21795, &quot;_id&quot; : ObjectId(&quot;50fdca1083ce409d7d000078&quot;) }
&lt;p&gt; on : s0 Timestamp(3000, 0) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 21795, &quot;_id&quot; : ObjectId(&quot;50fdca1083ce409d7d000078&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 22093, &quot;_id&quot; : ObjectId(&quot;50fdc24183ce402d30000230&quot;) }
&lt;p&gt; on : s0 Timestamp(4000, 0) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 22093, &quot;_id&quot; : ObjectId(&quot;50fdc24183ce402d30000230&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 22152, &quot;_id&quot; : ObjectId(&quot;50fdd19383ce40d07d0003f3&quot;) }
&lt;p&gt; on : s0 Timestamp(5000, 0) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 22152, &quot;_id&quot; : ObjectId(&quot;50fdd19383ce40d07d0003f3&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 22179, &quot;_id&quot; : ObjectId(&quot;50fdf58883ce40751e0004f5&quot;) }
&lt;p&gt; on : s1 Timestamp(5000, 1) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 22179, &quot;_id&quot; : ObjectId(&quot;50fdf58883ce40751e0004f5&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : 22204, &quot;_id&quot; : ObjectId(&quot;50fdd4db83ce40d67d000560&quot;) }
&lt;p&gt; on : s1 Timestamp(4000, 4) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : 22204, &quot;_id&quot; : ObjectId(&quot;50fdd4db83ce40d67d000560&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; &lt;/p&gt;
{ &quot;user.id&quot; : &quot;22215&quot;, &quot;_id&quot; : ObjectId(&quot;50fde18a83ce40d50b00031c&quot;) }
&lt;p&gt; on : s1 Timestamp(4000, 5) &lt;br/&gt;
			&lt;/p&gt;
{ &quot;user.id&quot; : &quot;22215&quot;, &quot;_id&quot; : ObjectId(&quot;50fde18a83ce40d50b00031c&quot;) }
&lt;p&gt; --&amp;gt;&amp;gt; { &quot;user.id&quot; : &lt;/p&gt;
{ $maxKey : 1 }
&lt;p&gt;, &quot;_id&quot; : &lt;/p&gt;
{ $maxKey : 1 }
&lt;p&gt; } on : s1 Timestamp(3000, 3) &lt;/p&gt;
	{  &quot;_id&quot; : &quot;sitemedia&quot;,  &quot;partitioned&quot; : false,  &quot;primary&quot; : &quot;s1&quot; }
	{  &quot;_id&quot; : &quot;test&quot;,  &quot;partitioned&quot; : false,  &quot;primary&quot; : &quot;s1&quot; }


&lt;p&gt;Our application work flow is as follows:&lt;/p&gt;

&lt;p&gt;1) Insert a new document to the collection with a UserId.&lt;br/&gt;
2) Take the returned MongoId, and then update the document with some additional meta data about the document including where the actual image is stored and other relational data&lt;/p&gt;

&lt;p&gt;What we are seeing is that after the update, doing a db.sitemedia.find({_id:ObjectId($idhash)}) on the mongo shell connected to mongos return an empty result while doing a db.sitemedia.find({_id:ObjectId($idhash)}).count() returns 1&lt;/p&gt;

&lt;p&gt;Connecting to the two shards and running find at the mongo shell shows the mongo object living on the wrong shard.  Attaching a Paste bin of our log file showing the insert and update results and what is getting pushed in to the system.&lt;/p&gt;

&lt;p&gt;What we are noticing is that on the first insert since we don&apos;t have a MongoId yet, Mongo just inserts the document into the default shard.  However, because the index is also based on userid, the document should have been placed on shard0 and not shard1. the subsequent update shows that mongos sends the update to both shards and returns a success because shard1 did the update. however on a find mongos can&apos;t find the result on shard0 since the document is living on shard1.&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://pastebin.com/3z0UNBZM&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://pastebin.com/3z0UNBZM&lt;/a&gt;&lt;/p&gt;</description>
                <environment>All nodes running Ubuntu 12.10 on Rackspace Cloud Server instances&lt;br/&gt;
Config servers on their own nodes&lt;br/&gt;
mongos running on same node as app server (php + apache)&lt;br/&gt;
2 mongod shards are 3 node replica sets all running on separate nodes</environment>
        <key id="63181">SERVER-8320</key>
            <summary>Inserting with a compound shard key results in data on wrong shard</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="randolph@mongodb.com">Randolph Tan</assignee>
                                    <reporter username="vsco">Visual Supply Co</reporter>
                        <labels>
                    </labels>
                <created>Thu, 24 Jan 2013 19:29:01 +0000</created>
                <updated>Thu, 12 Jan 2023 19:00:24 +0000</updated>
                            <resolved>Wed, 13 Feb 2013 21:35:36 +0000</resolved>
                                    <version>2.2.2</version>
                                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="249022" author="renctan" created="Thu, 24 Jan 2013 21:18:38 +0000"  >&lt;p&gt;It is currently considered an error to modify the values that are part of the shard key of an existing document. The current work around is to retrieve the existing one, delete it, and insert a new one with the new value (see also &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-7379&quot; title=&quot;Immutable shardkey becomes mutable &quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-7379&quot;&gt;&lt;del&gt;SERVER-7379&lt;/del&gt;&lt;/a&gt;).&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="53414">SERVER-7379</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 24 Jan 2013 21:18:38 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 3 weeks, 6 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>jack.mulrow@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 3 weeks, 6 days 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>randolph@mongodb.com</customfieldvalue>
            <customfieldvalue>vsco</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrn9u7:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>40699</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;1) Insert a new document with incomplete shard key (just a user id) that should result in the document sitting on the non default shard.&lt;br/&gt;
2) then update the document&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|ht060f:</customfieldvalue>

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