<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:57:37 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-1639] Failed to update an object with null value in shard key</title>
                <link>https://jira.mongodb.org/browse/SERVER-1639</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;// There are 2 documents in collection virus already.&lt;br/&gt;
&amp;gt; db.virus.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c6cf85f1dc3e52659865ff2&quot;), &quot;did&quot; : 1, &quot;recv_time&quot; : 1, &quot;n&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4c6cf86f1dc3e52659865ff3&quot;), &quot;did&quot; : 1, &quot;recv_time&quot; : 2, &quot;n&quot; : 2 }

&lt;p&gt;// Using shard key and operator in criteria, and using modifier $set in objNew&lt;br/&gt;
&amp;gt; db.virus.update({did:1,recv_time:{$gte:3}},{$set:{n:3}},true,false)&lt;/p&gt;

&lt;p&gt;// document inserted even recv_time is null&lt;br/&gt;
&amp;gt; db.virus.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c6cf85f1dc3e52659865ff2&quot;), &quot;did&quot; : 1, &quot;recv_time&quot; : 1, &quot;n&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4c6cf86f1dc3e52659865ff3&quot;), &quot;did&quot; : 1, &quot;recv_time&quot; : 2, &quot;n&quot; : 2 }
{ &quot;_id&quot; : ObjectId(&quot;4c6cf8f55d602a71c933a105&quot;), &quot;did&quot; : 1, &quot;n&quot; : 3 }

&lt;p&gt;// could query with recv_time==null &lt;br/&gt;
&amp;gt; db.virus.find(&lt;/p&gt;
{recv_time:null}
&lt;p&gt;)&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c6cf8f55d602a71c933a105&quot;), &quot;did&quot; : 1, &quot;n&quot; : 3 }

&lt;p&gt;// Can&apos;t update via ObjectId&lt;br/&gt;
&amp;gt; db.virus.update({_id:ObjectId(&quot;4c6cf8f55d602a71c933a105&quot;)},&lt;/p&gt;
{n:4}
&lt;p&gt;)&lt;br/&gt;
right object doesn&apos;t have full shard key&lt;/p&gt;

&lt;p&gt;// Can&apos;t update by criteria with shard key&lt;br/&gt;
&amp;gt; db.virus.update(&lt;/p&gt;
{did:1,recv_time:null}
&lt;p&gt;,&lt;/p&gt;
{n:4}
&lt;p&gt;)&lt;br/&gt;
shard key must be in update object&lt;/p&gt;</description>
                <environment></environment>
        <key id="12834">SERVER-1639</key>
            <summary>Failed to update an object with null value in shard key</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="mathias@mongodb.com">Mathias Stearn</assignee>
                                    <reporter username="stewwu">Che-Ching Wu</reporter>
                        <labels>
                    </labels>
                <created>Thu, 19 Aug 2010 10:17:07 +0000</created>
                <updated>Tue, 29 May 2012 14:53:22 +0000</updated>
                            <resolved>Thu, 26 Aug 2010 03:33:53 +0000</resolved>
                                    <version>1.6.0</version>
                                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="17432" author="redbeard0531" created="Thu, 26 Aug 2010 03:33:38 +0000"  >&lt;p&gt;Ahh, I see the issue. Sharded updates must know exactly the shard_key of the document you wish to update. The code currently only checks that you have something for the shard key, not that it is an exact match. I&apos;ve created a case for that and linked it to this one.&lt;/p&gt;

&lt;p&gt;For your current situation I&apos;d suggest deleting all objects w/o a shard key, and modifying your code to ensure that all updates (especially upserts) include an exact match for the shard key.&lt;/p&gt;</comment>
                            <comment id="17430" author="stewwu" created="Thu, 26 Aug 2010 03:18:01 +0000"  >&lt;p&gt;Here is the way:&lt;/p&gt;

&lt;p&gt;&amp;gt; db.virus.update({did:1,recv_time:{$gte:3}},{$set:{n:3}},true,false) &lt;/p&gt;</comment>
                            <comment id="17386" author="redbeard0531" created="Wed, 25 Aug 2010 18:00:37 +0000"  >&lt;p&gt;I take it back, I don&apos;t think there is a bug in update, I just typoed while testing:&lt;/p&gt;


&lt;p&gt;&amp;gt; db.bar.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c755696d41c2ec36db0626b&quot;), &quot;key&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4c755699d41c2ec36db0626c&quot;), &quot;key&quot; : null }

&lt;p&gt;&amp;gt; db.bar.update(&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c755699d41c2ec36db0626c&quot;), &quot;key&quot; : null }
&lt;p&gt;, {$set: {n:1}})&lt;br/&gt;
&amp;gt; db.bar.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c755696d41c2ec36db0626b&quot;), &quot;key&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4c755699d41c2ec36db0626c&quot;), &quot;key&quot; : null, &quot;n&quot; : 1 }

&lt;p&gt;&amp;gt; db.bar.update(&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c755699d41c2ec36db0626c&quot;)}
&lt;p&gt;,&lt;/p&gt;
{&quot;key&quot; : null, n:2}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.bar.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c755696d41c2ec36db0626b&quot;), &quot;key&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4c755699d41c2ec36db0626c&quot;), &quot;key&quot; : null, &quot;n&quot; : 2 }


&lt;p&gt;I&apos;m still curious how you managed to insert an object w/o the shard key. Mongos should be preventing that and if it isn&apos;t then that is the bug&lt;/p&gt;</comment>
                            <comment id="17383" author="redbeard0531" created="Wed, 25 Aug 2010 17:54:45 +0000"  >&lt;p&gt;How did you insert an object w/o a shard key? You should get an error like this:&lt;/p&gt;

&lt;p&gt;&amp;gt; db.bar.insert(&lt;/p&gt;
{key:1}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.bar.insert(&lt;/p&gt;
{key:null}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.bar.insert({})&lt;br/&gt;
tried to insert object without shard key&lt;br/&gt;
&amp;gt; db.bar.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4c755696d41c2ec36db0626b&quot;), &quot;key&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4c755699d41c2ec36db0626c&quot;), &quot;key&quot; : null }


&lt;p&gt;Note that explicitly storing null is different from missing fields, even though querying with null will match missing fields.&lt;/p&gt;

&lt;p&gt;As for the updates, there is an actual bug, but your update commands are also incorrect. I beleave you want one of these (for an explicit null):&lt;/p&gt;

&lt;p&gt;db.virus.update(&lt;/p&gt;
{did:1,recv_time:null}
&lt;p&gt;,{$set:{n:4}}) &lt;br/&gt;
db.virus.update({_id: some_id}, &lt;/p&gt;
{did:1, recv_time:null, n:4}
&lt;p&gt;) &lt;/p&gt;

&lt;p&gt;see &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29&lt;/a&gt; for the difference between the two&lt;/p&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="12923">SERVER-1689</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>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 25 Aug 2010 17:54:45 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        13 years, 25 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>false</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            13 years, 25 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>stewwu</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hriiwf:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>21688</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|hri7nr:</customfieldvalue>

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