<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:22:03 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>[DRIVERS-660] Change updates to prefer target by the query</title>
                <link>https://jira.mongodb.org/browse/DRIVERS-660</link>
                <project id="10980" key="DRIVERS">Drivers</project>
                    <description>&lt;p&gt;Currently, replacement style updates target using the update rather than the query. We should change this to target using the query instead.&lt;/p&gt;

&lt;p&gt;As of today, we do not allow users to change the shard key for a document. If shard 1 owns the chunk with range (shardKey : min, shardKey : 500) and shard 2 owns the chunk with range (shardKey : 500, shardKey : max) and a user sends &lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.coll.update({shardKey : 100}, {shardKey : 800})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt; the update will be sent to shard 2 and we return &lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ok: 1.0, nMatched : 0)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt; We should actually get an ImmutableField error.&lt;/p&gt;

&lt;p&gt;Once we allow a user to update the shard key for a document (PM-1163), the above update should cause the document to change shards. However, since the update would be sent to shard 2, shard 1 will never actually see this update and the update will not  be applied. &lt;/p&gt;</description>
                <environment></environment>
        <key id="774665">DRIVERS-660</key>
            <summary>Change updates to prefer target by the query</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="13203">Gone away</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="arun.banala@mongodb.com">Arun Banala</reporter>
                        <labels>
                    </labels>
                <created>Wed, 22 May 2019 16:46:07 +0000</created>
                <updated>Fri, 27 Oct 2023 19:45:00 +0000</updated>
                            <resolved>Thu, 18 Jul 2019 19:27:42 +0000</resolved>
                                                                            <votes>0</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="2266036" author="jmikola@gmail.com" created="Thu, 30 May 2019 20:58:49 +0000"  >&lt;p&gt;Previous comments on this issue seem preoccupied with the &lt;tt&gt;save()&lt;/tt&gt; CRUD method. I don&apos;t think that&apos;s the right thing to be focus on. While it&apos;s true that the deprecated &lt;tt&gt;save()&lt;/tt&gt; CRUD method may do a replacement-style update with &lt;tt&gt;upsert: true&lt;/tt&gt; if the &lt;tt&gt;&amp;#95;id&lt;/tt&gt; is known at runtime (see: &lt;a href=&quot;https://github.com/jmikola/slides/blob/gh-pages/mongodb_dos_and_donts/img/save-flowchart-2.png&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;save flowchart&lt;/a&gt;), this more generally applies to &lt;em&gt;any&lt;/em&gt; replaceOne operation.&lt;/p&gt;

&lt;p&gt;The behavioral change in the OP is simply:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Previously, replacement-style &lt;tt&gt;update&lt;/tt&gt; commands would be routed to shards by the &lt;a href=&quot;https://docs.mongodb.com/manual/reference/command/update/#update-command-behaviors&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;update&lt;/tt&gt;&lt;/a&gt; document (i.e. replacement document).&lt;/li&gt;
	&lt;li&gt;After &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-39158&quot; title=&quot;Change updates to prefer target by the query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-39158&quot;&gt;&lt;del&gt;SERVER-39158&lt;/del&gt;&lt;/a&gt;, those same update commands will be routed by the &lt;tt&gt;filter&lt;/tt&gt; document.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The scenario described in the OP demonstrates a case where an &lt;tt&gt;update&lt;/tt&gt; could return successfully and not match anything, when the desired behavior would be to raise an ImmutableField error. While that seems harmless, if we revise that scenario to include an &lt;tt&gt;upsert: true&lt;/tt&gt; option on the &lt;tt&gt;update&lt;/tt&gt; command then we risk inserting a new document instead of raising an error.&lt;/p&gt;

&lt;p&gt;AFAICT, the relevant audit for ODMs and any other libraries would be any case where a replaceOne (with or without an upsert) might be executed internally. We can probably forego any query builders that allow users/applications to craft their own replacements, as that&apos;s no different than a user calling &lt;tt&gt;replaceOne()&lt;/tt&gt; directly through a driver.&lt;/p&gt;</comment>
                            <comment id="2264139" author="behackett" created="Wed, 29 May 2019 18:30:14 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=oleg.pudeyev&quot; class=&quot;user-hover&quot; rel=&quot;oleg.pudeyev&quot;&gt;oleg.pudeyev&lt;/a&gt;, a user of a driver can (and should, years ago) stop using the deprecated save() method. If the ODM they are using does a save() internally there is no way a user can avoid it.&lt;/p&gt;</comment>
                            <comment id="2264134" author="jeff.yemin" created="Wed, 29 May 2019 18:25:08 +0000"  >&lt;p&gt;I don&apos;t think Morphia has the sort of behavior that you seem to be describing.  All updates are done explicitly (either with a save or an update method call).  See &lt;a href=&quot;https://morphia.dev/1.5/getting-started/quick-tour/#saving-data&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://morphia.dev/1.5/getting-started/quick-tour/#saving-data&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="2264125" author="oleg.pudeyev" created="Wed, 29 May 2019 18:23:01 +0000"  >&lt;p&gt;I understand that. What confuses me is why ODMs are highlighted in the present discussion because it is equally possible to do those kinds of updates via drivers and my impression is they would result in incorrect behavior (lost updates) as well.&lt;/p&gt;</comment>
                            <comment id="2264099" author="behackett" created="Wed, 29 May 2019 18:11:38 +0000"  >&lt;p&gt;The issue isn&apos;t the ODM providing a save() method. The problem is ODMs essentially doing a save() internally to update model documents. &lt;/p&gt;</comment>
                            <comment id="2264084" author="oleg.pudeyev" created="Wed, 29 May 2019 18:03:24 +0000"  >&lt;p&gt;I will investigate whether Mongoid is affected after &lt;a href=&quot;https://jira.mongodb.org/browse/HELP-10000&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/HELP-10000&lt;/a&gt; unless priorities should be different.&lt;/p&gt;</comment>
                            <comment id="2262822" author="jeff.yemin" created="Tue, 28 May 2019 23:20:42 +0000"  >&lt;p&gt;Morphia does have a save method IIRC, so best we can do is to open a ticket to request that it be deprecated.&lt;/p&gt;


</comment>
                            <comment id="2262420" author="behackett" created="Tue, 28 May 2019 18:59:13 +0000"  >&lt;p&gt;Moving this back to triage. &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=shane.harvey&quot; class=&quot;user-hover&quot; rel=&quot;shane.harvey&quot;&gt;shane.harvey&lt;/a&gt; pointed out that this will break PyMODM. He also thinks this might affect Morphia (&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jeff.yemin&quot; class=&quot;user-hover&quot; rel=&quot;jeff.yemin&quot;&gt;jeff.yemin&lt;/a&gt;?). &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=oleg.pudeyev&quot; class=&quot;user-hover&quot; rel=&quot;oleg.pudeyev&quot;&gt;oleg.pudeyev&lt;/a&gt;, will this break Mongoid?&lt;/p&gt;</comment>
                            <comment id="2262158" author="ian@10gen.com" created="Tue, 28 May 2019 17:12:39 +0000"  >&lt;p&gt;all drivers have already deprecated save() so no need to do anything here.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="676879">SERVER-39158</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="860918">MONGOID-4759</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                            <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hupwc7:</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_22279" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Server Compat</customfieldname>
                        <customfieldvalues>
                                        <label>4.1</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    </customfields>
    </item>
</channel>
</rss>