<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:08:05 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-5168] Map Reduce Incorrectly Emitting null When a Constant Key is Used</title>
                <link>https://jira.mongodb.org/browse/SERVER-5168</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Running MapReduce with a constant key causes null to always be emitted.  This makes any scenario where you need to perform global aggregation on the server impossible.  While the repro code below is trivial, our actual production code performs much more sophisticated analysis logic on objects. &lt;/p&gt;

&lt;p&gt;The following repro code below will assert in the reduce function:&lt;/p&gt;

&lt;p&gt;db.items.mapReduce(function () {&lt;br/&gt;
    emit(&quot;foo&quot;, &lt;/p&gt;
{ a: 1 }
&lt;p&gt;);&lt;br/&gt;
}, function (key, values) {&lt;br/&gt;
    var sum = 0;&lt;br/&gt;
    values.forEach(function (value) &lt;/p&gt;
{
        sum += value.a;
    });&lt;br/&gt;
    emit(key, { a: sum });&lt;br/&gt;
}, { out: &quot;foo_out&quot; });&lt;br/&gt;
&lt;br/&gt;
        &quot;assertion&quot; : &quot;invoke failed: JS Error: TypeError: value has no properties nofile_b:2&quot;,&lt;br/&gt;
        &quot;assertionCode&quot; : 9004,&lt;br/&gt;
        &quot;errmsg&quot; : &quot;db assertion failure&quot;,&lt;br/&gt;
        &quot;ok&quot; : 0&lt;br/&gt;
&lt;br/&gt;
Note that just a simple change in the id causes the failure to go away (this is not functionally equivalent, nor is it a workaround, but it illustrates the bug):&lt;br/&gt;
&lt;br/&gt;
db.items.mapReduce(function () {&lt;br/&gt;
    emit(this._id, { a: 1 });&lt;br/&gt;
}, function (key, values) {&lt;br/&gt;
    var sum = 0;&lt;br/&gt;
    values.forEach(function (value) {        sum += value.a;    }
&lt;p&gt;);&lt;br/&gt;
    emit(key, &lt;/p&gt;
{ a: sum }
&lt;p&gt;);&lt;br/&gt;
}, &lt;/p&gt;
{ out: &quot;foo&quot; }
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;        &quot;result&quot; : &quot;foo&quot;,&lt;br/&gt;
        &quot;timeMillis&quot; : 7951,&lt;br/&gt;
        &quot;counts&quot; : &lt;/p&gt;
{
                &quot;input&quot; : 83338,
                &quot;emit&quot; : 83338,
                &quot;reduce&quot; : 0,
                &quot;output&quot; : 83338
        }
&lt;p&gt;,&lt;br/&gt;
        &quot;ok&quot; : 1,&lt;/p&gt;


</description>
                <environment>Windows Server 2K8R2 x64</environment>
        <key id="31997">SERVER-5168</key>
            <summary>Map Reduce Incorrectly Emitting null When a Constant Key is Used</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="optimiz3">Alexander Nagy</reporter>
                        <labels>
                            <label>mapreduce,</label>
                            <label>mongos</label>
                            <label>query</label>
                    </labels>
                <created>Fri, 2 Mar 2012 03:56:26 +0000</created>
                <updated>Wed, 15 Aug 2012 14:24:08 +0000</updated>
                            <resolved>Wed, 7 Mar 2012 04:24:46 +0000</resolved>
                                    <version>2.0.3</version>
                                                    <component>JavaScript</component>
                    <component>MapReduce</component>
                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="96218" author="eliot" created="Wed, 7 Mar 2012 04:24:38 +0000"  >&lt;p&gt;You can&apos;t emit from a reduce function.&lt;br/&gt;
You have to return it.&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>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 7 Mar 2012 04:24:38 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 50 weeks 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, 50 weeks 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>optimiz3</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|hrob7z:</customfieldvalue>

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

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

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