<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:12:40 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-6775] findandmodify incorrectly modifies/optimizes the query for the update operation</title>
                <link>https://jira.mongodb.org/browse/SERVER-6775</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Console session: &lt;a href=&quot;https://gist.github.com/3355357&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/3355357&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take a look at the query for the update (at line 44). Seems MongoDB is rewriting my query, but it leaves the original query in place. (See also the comments on this gist; there&apos;s &lt;b&gt;some&lt;/b&gt; insight in the code, but not much.)&lt;/p&gt;

&lt;p&gt;The reason I stumbled upon this is that I was trying to do some scripted explains on my profile data, and got something like this: &lt;a href=&quot;http://paste.roguecoders.com/p/efd3829bba5ab5fd19ba8bb1a073da6a.txt&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://paste.roguecoders.com/p/efd3829bba5ab5fd19ba8bb1a073da6a.txt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note the second clause (which should be entirely redundant because Mongo is selecting one explicit unique record (the _id)). This gives me an empty BasicCursor.&lt;/p&gt;

&lt;p&gt;From here: &lt;a href=&quot;https://groups.google.com/d/topic/mongodb-user/we4kDRdE4GM/discussion&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/d/topic/mongodb-user/we4kDRdE4GM/discussion&lt;/a&gt; (Kristina and Derick both suggested I file this in Jira).&lt;/p&gt;</description>
                <environment>Linux. Looks like it happens everywhere, in the code.</environment>
        <key id="47262">SERVER-6775</key>
            <summary>findandmodify incorrectly modifies/optimizes the query for the update operation</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="aaron">Aaron Staple</assignee>
                                    <reporter username="scoates">Sean Coates</reporter>
                        <labels>
                            <label>findAndModify</label>
                            <label>profiling</label>
                            <label>update</label>
                    </labels>
                <created>Wed, 15 Aug 2012 22:03:34 +0000</created>
                <updated>Fri, 15 Feb 2013 15:06:28 +0000</updated>
                            <resolved>Thu, 16 Aug 2012 17:05:59 +0000</resolved>
                                    <version>2.0.4</version>
                                                    <component>Internal Code</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="153948" author="scoates" created="Thu, 16 Aug 2012 13:56:08 +0000"  >&lt;p&gt;I guess you can close this. It&apos;s still really confusing (the way it shows up in the profiler), but may not actually be a bug after all.&lt;/p&gt;</comment>
                            <comment id="153816" author="aaron" created="Wed, 15 Aug 2012 23:15:56 +0000"  >&lt;p&gt;Hi Sean,&lt;/p&gt;

&lt;p&gt;It should work fine generally.  Here&apos;s a bit of an explanation.  Your example is basically&lt;/p&gt;

&lt;p&gt;{ $or:[ &lt;/p&gt;
{ _id:A }
&lt;p&gt;, &lt;/p&gt;
{ _id:B }
&lt;p&gt; ] }&lt;/p&gt;

&lt;p&gt;In the example you sent the explain link from it&apos;s getting transformed to&lt;/p&gt;

&lt;p&gt;{ _id:A, $or:[ &lt;/p&gt;
{ _id:A }
&lt;p&gt;, &lt;/p&gt;
{ _id:B }
&lt;p&gt; ] }&lt;/p&gt;

&lt;p&gt;The second $or clause can&apos;t produce any results, so what you&apos;re seeing when explaining the second clause is a dummy basic cursor that doesn&apos;t scan anything.  There is a ticket to make this reporting more user friendly, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-4325&quot; title=&quot;BasicCursor may be reported by explain when a query cannot match any documents&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-4325&quot;&gt;&lt;del&gt;SERVER-4325&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We could potentially remove $or clauses when find and modify rewrites the query, since the positional operator doesn&apos;t look inside $or clauses.  This might make the queries a bit faster but is probably not strictly necessary.  (I haven&apos;t worked on the find and modify code myself though.)&lt;/p&gt;</comment>
                            <comment id="153812" author="scoates" created="Wed, 15 Aug 2012 22:59:08 +0000"  >&lt;p&gt;The only practical error I&apos;ve seen is that in .explain() I get a BasicCursor that showed up as non-indexed in my analysis tools. It seems to &lt;b&gt;work&lt;/b&gt; just fine as it it, but I&apos;m not sure that would be the case for every similar query.&lt;/p&gt;

&lt;p&gt;S&lt;/p&gt;</comment>
                            <comment id="153811" author="aaron" created="Wed, 15 Aug 2012 22:55:36 +0000"  >&lt;p&gt;Sean - are you experiencing a functional error of some kind?&lt;/p&gt;</comment>
                    </comments>
                    <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, 15 Aug 2012 22:55:36 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 26 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10020"><![CDATA[Linux]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>scoates</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrnrq7:</customfieldvalue>

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

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

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