<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:59:27 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-2269] Map/reduce with sorting fail</title>
                <link>https://jira.mongodb.org/browse/SERVER-2269</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;When i trying to make sort on map/reduce it fails with &quot;db assertion failure&quot;&lt;br/&gt;
I wrote code in python, here it is:&lt;/p&gt;

&lt;p&gt;                    m = Code(&quot;&quot;&quot;function() {&lt;br/&gt;
		    data = {};&lt;br/&gt;
		    res = &apos;&apos;&lt;br/&gt;
		    if(this.result_id) {&lt;br/&gt;
		        res=&lt;/p&gt;
{&apos;objectid&apos;:this.result_id.toString()}
&lt;p&gt;;&lt;br/&gt;
		    } else &lt;/p&gt;
{
		        res=this.result;
		    }
&lt;p&gt;		    emit(this.data, res);&lt;br/&gt;
		}&quot;&quot;&quot;)&lt;br/&gt;
		r = Code(&quot;&quot;&quot;function(k,values) { &lt;br/&gt;
		    data={};&lt;br/&gt;
		    for(var i=0; i&amp;lt;values.length; i++ ) &lt;/p&gt;
{
		        for(attr in values[i])
		            data[attr]=values[i][attr];
		    }
&lt;p&gt;		    return data&lt;br/&gt;
		}&quot;&quot;&quot;)&lt;/p&gt;


&lt;p&gt;		res = self.db.tasks.map_reduce(m,r,query=&lt;/p&gt;
{&apos;job_id&apos;:job_id}
&lt;p&gt;,sort=&lt;/p&gt;
{&apos;position&apos;:pymongo.ASCENDING}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;But when i turn off sorting it works pretty fine.&lt;/p&gt;</description>
                <environment>Ubuntu 10.10 2.6.35-23-generic #41-Ubuntu SMP Wed Nov 24 11:55:36 UTC 2010 x86_64 GNU/Linux&lt;br/&gt;
python 2.6.6&lt;br/&gt;
pymongo 1.9</environment>
        <key id="14049">SERVER-2269</key>
            <summary>Map/reduce with sorting fail</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="-1">Unassigned</assignee>
                                    <reporter username="creotiv">Andrey Nikishaev</reporter>
                        <labels>
                    </labels>
                <created>Wed, 22 Dec 2010 08:39:30 +0000</created>
                <updated>Tue, 22 May 2012 15:46:29 +0000</updated>
                            <resolved>Sun, 26 Dec 2010 06:13:31 +0000</resolved>
                                    <version>1.6.5</version>
                                                    <component>Build</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="21806" author="eliot" created="Sun, 26 Dec 2010 06:13:25 +0000"  >&lt;p&gt;You need an index on job_id,position in order to use that.&lt;/p&gt;</comment>
                            <comment id="21713" author="creotiv" created="Wed, 22 Dec 2010 15:52:54 +0000"  >&lt;p&gt;Server version: Tried 1.4.4, 1.6.5, 1.7.4&lt;/p&gt;

&lt;p&gt;Python traceback:&lt;/p&gt;

&lt;p&gt;Traceback (most recent call last):&lt;br/&gt;
  File &quot;map-reduce.py&quot;, line 87, in &amp;lt;module&amp;gt;&lt;br/&gt;
    reduce_job(&apos;4d121ac2ccab997705050000&apos;)&lt;br/&gt;
  File &quot;map-reduce.py&quot;, line 52, in reduce_job&lt;br/&gt;
    res =&lt;br/&gt;
db.tasks.map_reduce(m,r,sort=&lt;/p&gt;
{&apos;position&apos;:pymongo.ASCENDING}
&lt;p&gt;,query=&lt;/p&gt;
{&apos;job_id&apos;:ObjectId(job_id)}
&lt;p&gt;)&lt;br/&gt;
  File&lt;br/&gt;
&quot;/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.egg/pymongo/collection.py&quot;,&lt;br/&gt;
line 943, in map_reduce&lt;br/&gt;
    map=map, reduce=reduce, **kwargs)&lt;br/&gt;
  File&lt;br/&gt;
&quot;/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.egg/pymongo/database.py&quot;,&lt;br/&gt;
line 293, in command&lt;br/&gt;
    msg, allowable_errors)&lt;br/&gt;
  File&lt;br/&gt;
&quot;/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.egg/pymongo/helpers.py&quot;,&lt;br/&gt;
line 119, in _check_command_response&lt;br/&gt;
    raise OperationFailure(msg % response&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;errmsg&amp;quot;&amp;#93;&lt;/span&gt;)&lt;br/&gt;
pymongo.errors.OperationFailure: command SON([(&apos;mapreduce&apos;, u&apos;tasks&apos;),&lt;br/&gt;
(&apos;sort&apos;, &lt;/p&gt;
{&apos;position&apos;: 1}
&lt;p&gt;), (&apos;query&apos;, &lt;/p&gt;
{&apos;job_id&apos;:
ObjectId(&apos;4d121ac2ccab997705050000&apos;)}
&lt;p&gt;), (&apos;reduce&apos;, Code(&apos;function(k,values)&lt;br/&gt;
{ \n\t    data={};\n\t    for(var i=0; i&amp;lt;values.length; i++ ) &lt;/p&gt;
{\n\t
 for(attr in values[i])\n\t            data[attr]=values[i][attr];\n\t
 }
&lt;p&gt;\n\t    return data\n\t}&apos;, {})), (&apos;map&apos;, Code(&quot;function() &lt;/p&gt;
{\n\t    data =
{}
&lt;p&gt;;\n\t    res = &apos;&apos;\n\t    if(this.result_id) {\n\t&lt;br/&gt;
 res=&lt;/p&gt;
{&apos;objectid&apos;:this.result_id.toString()}
&lt;p&gt;;\n\t    } else &lt;/p&gt;
{\n\t
 res=this.result;\n\t    }
&lt;p&gt;\n\t\tres&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;position&amp;#39;&amp;#93;&lt;/span&gt; = this.position;\n\t&lt;br/&gt;
 emit(this.data, res);\n\t}&quot;, {}))]) failed: db assertion failure&lt;/p&gt;


&lt;p&gt;Mongo log:&lt;/p&gt;

&lt;p&gt;Wed Dec 22 17:36:56 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn144&amp;#93;&lt;/span&gt; CMD: drop&lt;br/&gt;
seotools.tmp.mr.mapreduce_1293032215_1&lt;br/&gt;
Wed Dec 22 17:36:56 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn144&amp;#93;&lt;/span&gt; CMD: drop&lt;br/&gt;
seotools.tmp.mr.mapreduce_1293032215_1_inc&lt;br/&gt;
Wed Dec 22 17:36:56 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn144&amp;#93;&lt;/span&gt; Assertion: 13284:best guess plan requested,&lt;br/&gt;
but scan and order required: query: &lt;/p&gt;
{ job_id:
ObjectId(&apos;4d121ac2ccab997705050000&apos;) }
&lt;p&gt; order: &lt;/p&gt;
{ position: 1 }
&lt;p&gt; choices: {&lt;br/&gt;
$natural: 1 }&lt;br/&gt;
Wed Dec 22 17:36:56 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn144&amp;#93;&lt;/span&gt; mr failed, removing collection&lt;br/&gt;
Wed Dec 22 17:36:56 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn144&amp;#93;&lt;/span&gt; CMD: drop&lt;br/&gt;
seotools.tmp.mr.mapreduce_1293032215_1&lt;br/&gt;
Wed Dec 22 17:36:56 &lt;span class=&quot;error&quot;&gt;&amp;#91;conn144&amp;#93;&lt;/span&gt; CMD: drop&lt;br/&gt;
seotools.tmp.mr.mapreduce_1293032215_1_inc&lt;/p&gt;



&lt;p&gt;In attachment file that reproduce problem.&lt;/p&gt;

&lt;p&gt;On version 1.4.4 i also notified that if sort param pass before query param&lt;br/&gt;
then it works but with big number of documents it return null.&lt;br/&gt;
i mean when we use:&lt;/p&gt;

&lt;p&gt;res = self.db.tasks.map_reduce(m,r,sort=&lt;/p&gt;
{&apos;position&apos;:pymongo.ASCENDING}
&lt;p&gt;,&lt;br/&gt;
query=&lt;/p&gt;
{&apos;job_id&apos;:job_id}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;instead:&lt;/p&gt;

&lt;p&gt;res =&lt;br/&gt;
self.db.tasks.map_reduce(m,r,query=&lt;/p&gt;
{&apos;job_id&apos;:job_id}
&lt;p&gt;,sort=&lt;/p&gt;
{&apos;position&apos;:pymongo.ASCENDING}
&lt;p&gt;)&lt;/p&gt;


&lt;p&gt;Best regards,&lt;/p&gt;

&lt;p&gt;Andrey Nikishaev&lt;/p&gt;

&lt;p&gt;Blog           &lt;a href=&quot;http://creotiv.in.ua/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://creotiv.in.ua/&lt;/a&gt;&lt;br/&gt;
Skype         creotiv.in.ua&lt;/p&gt;



&lt;p&gt;2010/12/22 Eliot Horowitz (JIRA) &amp;lt;jira@mongodb.org&amp;gt;&lt;/p&gt;
</comment>
                            <comment id="21712" author="eliot" created="Wed, 22 Dec 2010 15:24:52 +0000"  >&lt;p&gt;Can you send:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;server log&lt;/li&gt;
	&lt;li&gt;server version&lt;/li&gt;
	&lt;li&gt;full error message&lt;/li&gt;
	&lt;li&gt;sample document&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="39190">CSHARP-472</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="10688" name="map-reduce.py" size="1863" author="creotiv" created="Wed, 22 Dec 2010 15:52:55 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10012"><![CDATA[Major Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 22 Dec 2010 15:24:52 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        13 years, 8 weeks, 3 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>
                            13 years, 8 weeks, 3 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="10020"><![CDATA[Linux]]></customfieldvalue>

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

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

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

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