<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:59:30 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-2286] slaveOk is ignored for group() and mapReduce(), these are allowed to run on slave always</title>
                <link>https://jira.mongodb.org/browse/SERVER-2286</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;this is easy to reproduce:&lt;/p&gt;

&lt;p&gt;foo:SECONDARY&amp;gt; db.test.find()&lt;br/&gt;
error: &lt;/p&gt;
{ &quot;$err&quot; : &quot;not master and slaveok=false&quot;, &quot;code&quot; : 13435 }
&lt;p&gt;foo:SECONDARY&amp;gt; db.test.group({initial: &lt;/p&gt;
{n:0}
&lt;p&gt;, reduce: function(obj,out){out.n += obj.a;}})&lt;br/&gt;
[ &lt;/p&gt;
{ &quot;n&quot; : 3 }
&lt;p&gt; ]&lt;br/&gt;
foo:SECONDARY&amp;gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="14078">SERVER-2286</key>
            <summary>slaveOk is ignored for group() and mapReduce(), these are allowed to run on slave always</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="antoine">Antoine Girbal</assignee>
                                    <reporter username="antoine">Antoine Girbal</reporter>
                        <labels>
                    </labels>
                <created>Fri, 24 Dec 2010 01:25:26 +0000</created>
                <updated>Tue, 12 Jul 2016 00:18:46 +0000</updated>
                            <resolved>Wed, 5 Jan 2011 07:15:33 +0000</resolved>
                                                    <fixVersion>1.7.5</fixVersion>
                                                        <votes>1</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="22163" author="auto" created="Thu, 6 Jan 2011 20:53:04 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2286&quot; title=&quot;slaveOk is ignored for group() and mapReduce(), these are allowed to run on slave always&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2286&quot;&gt;&lt;del&gt;SERVER-2286&lt;/del&gt;&lt;/a&gt;: change to allow operations on slave if not replSet&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/80fecd37e37aea6f55dae25b4a63174061fea598&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/80fecd37e37aea6f55dae25b4a63174061fea598&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="22076" author="auto" created="Wed, 5 Jan 2011 07:19:24 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2286&quot; title=&quot;slaveOk is ignored for group() and mapReduce(), these are allowed to run on slave always&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2286&quot;&gt;&lt;del&gt;SERVER-2286&lt;/del&gt;&lt;/a&gt;: slaveOk is ignored for group() and mapReduce(), these are allowed to run on slave always&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/f5e2323933025844cd76e9f31025f8dc1747e55d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/f5e2323933025844cd76e9f31025f8dc1747e55d&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="22074" author="antoine" created="Wed, 5 Jan 2011 07:15:33 +0000"  >&lt;p&gt;added test in jstests/replsets/groupAndMapReduce.js&lt;/p&gt;</comment>
                            <comment id="22073" author="antoine" created="Wed, 5 Jan 2011 07:14:34 +0000"  >&lt;p&gt;ok the error raise is now correct:&lt;/p&gt;

&lt;p&gt;foo:SECONDARY&amp;gt; db.getMongo().slaveOk = true&lt;br/&gt;
true&lt;br/&gt;
foo:SECONDARY&amp;gt; db.users.mapReduce(map, reduce, &quot;outcoll&quot;);&lt;br/&gt;
Tue Jan  4 22:49:51 uncaught exception: map reduce failed: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;not master&quot;, &quot;ok&quot; : 0 }</comment>
                            <comment id="22067" author="eliot" created="Wed, 5 Jan 2011 04:15:10 +0000"  >&lt;p&gt;1)  yes.   if inline results are not wanted, then we should check _isMaster right at the start&lt;/p&gt;

&lt;p&gt;2) not sure I understand.  Can you send the full example?&lt;/p&gt;</comment>
                            <comment id="22064" author="antoine" created="Wed, 5 Jan 2011 01:01:57 +0000"  >&lt;p&gt;For map/reduce, I had to tweak several calls to exist() and count() within the map reduce, to always have &quot;slaveOk&quot;.&lt;/p&gt;

&lt;p&gt;foo:SECONDARY&amp;gt; db.users.findOne()&lt;br/&gt;
{&lt;br/&gt;
	&quot;_id&quot; : ObjectId(&quot;4d1009c7262bb4b94af1cea4&quot;),&lt;br/&gt;
	&quot;fn&quot; : &quot;usroatjnmo&quot;,&lt;br/&gt;
	&quot;ln&quot; : &quot;lparjzmorx&quot;&lt;br/&gt;
}&lt;br/&gt;
foo:SECONDARY&amp;gt; map = function() &lt;/p&gt;
{ emit(this.ln, 1); }
&lt;p&gt;foo:SECONDARY&amp;gt; reduce = function(key, vals) { var sum = 0; for (var val in vals) &lt;/p&gt;
{ sum += val; }
&lt;p&gt; return sum;  }&lt;br/&gt;
foo:SECONDARY&amp;gt; db.getMongo().slaveOk = false&lt;br/&gt;
false&lt;br/&gt;
foo:SECONDARY&amp;gt; db.users.mapReduce(map, reduce, {out: { &quot;inline&quot; : 1}});&lt;br/&gt;
Tue Jan  4 16:43:40 uncaught exception: map reduce failed: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;not master&quot;, &quot;ok&quot; : 0 }
&lt;p&gt;foo:SECONDARY&amp;gt; db.users.mapReduce(map, reduce, &quot;outcoll&quot;);&lt;br/&gt;
Tue Jan  4 16:43:48 uncaught exception: map reduce failed: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;not master&quot;, &quot;ok&quot; : 0 }
&lt;p&gt;foo:SECONDARY&amp;gt; db.getMongo().slaveOk = true&lt;br/&gt;
true&lt;br/&gt;
foo:SECONDARY&amp;gt; db.users.mapReduce(map, reduce, &quot;outcoll&quot;);&lt;br/&gt;
Tue Jan  4 16:44:03 uncaught exception: map reduce failed: {&lt;br/&gt;
	&quot;assertion&quot; : &quot;replSet error : logOp() but not primary?&quot;,&lt;br/&gt;
	&quot;assertionCode&quot; : 13312,&lt;br/&gt;
	&quot;errmsg&quot; : &quot;db assertion failure&quot;,&lt;br/&gt;
	&quot;ok&quot; : 0&lt;br/&gt;
}&lt;br/&gt;
foo:SECONDARY&amp;gt; db.users.mapReduce(map, reduce, {out: { &quot;inline&quot; : 1}});&lt;br/&gt;
{&lt;br/&gt;
	&quot;results&quot; : [&lt;br/&gt;
...&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;_id&quot; : &quot;zxjhcniatu&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;,&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;_id&quot; : &quot;zxjjjuxgeb&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;,&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;_id&quot; : &quot;zxxwkjajsg&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;,&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;_id&quot; : &quot;zyamwcrtrr&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;,&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;_id&quot; : &quot;zzobixwpuv&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;,&lt;/p&gt;
		{
			&quot;_id&quot; : &quot;zzucdarlws&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;	],&lt;br/&gt;
	&quot;timeMillis&quot; : 129,&lt;br/&gt;
	&quot;counts&quot; : &lt;/p&gt;
{
		&quot;input&quot; : 4000,
		&quot;emit&quot; : 4000,
		&quot;output&quot; : 4000
	}
&lt;p&gt;,&lt;br/&gt;
	&quot;ok&quot; : 1,&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Questions:&lt;br/&gt;
1) when slaveOk=false and trying to write to collection, is the current exception &quot;logOp() but not primary&quot;. Most likely exception needs to happen before that right?&lt;br/&gt;
It seems mongod creates a new NS for tmp collection, then fails when logging it, which is too late.&lt;/p&gt;

&lt;p&gt;2) if I run the mr on master and output to table, the table data looks like:&lt;/p&gt;
{ &quot;_id&quot; : &quot;btkcfrljxh&quot;, &quot;value&quot; : &quot;00&quot; }
{ &quot;_id&quot; : &quot;btmhnalouu&quot;, &quot;value&quot; : &quot;00&quot; }

&lt;p&gt;whereas inline it is like&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;_id&quot; : &quot;zzobixwpuv&quot;,
			&quot;value&quot; : 1
		}
&lt;p&gt;,&lt;/p&gt;
		{
			&quot;_id&quot; : &quot;zzucdarlws&quot;,
			&quot;value&quot; : 1
		}

&lt;p&gt;why is value different?&lt;/p&gt;</comment>
                            <comment id="22062" author="antoine" created="Tue, 4 Jan 2011 23:30:05 +0000"  >&lt;p&gt;fixed the group cmd by switching return value of slaveOk() in group.cpp&lt;/p&gt;

&lt;p&gt;foo:SECONDARY&amp;gt; db.getMongo().setSlaveOk()&lt;br/&gt;
foo:SECONDARY&amp;gt; db.test.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4d239463ce489e240201f9dc&quot;), &quot;a&quot; : 1 }
{ &quot;_id&quot; : ObjectId(&quot;4d23946ece489e240201f9dd&quot;), &quot;a&quot; : 2 }
&lt;p&gt;foo:SECONDARY&amp;gt; db.test.group({initial: &lt;/p&gt;
{n:0}
&lt;p&gt;, reduce: function(obj,out){out.n += obj.a;}}) &lt;br/&gt;
[ &lt;/p&gt;
{ &quot;n&quot; : 3 }
&lt;p&gt; ]&lt;br/&gt;
foo:SECONDARY&amp;gt; db.getMongo().slaveOk = false&lt;br/&gt;
false&lt;br/&gt;
foo:SECONDARY&amp;gt; db.test.find()&lt;br/&gt;
error: &lt;/p&gt;
{ &quot;$err&quot; : &quot;not master and slaveok=false&quot;, &quot;code&quot; : 13435 }
&lt;p&gt;foo:SECONDARY&amp;gt; db.test.group({initial: &lt;/p&gt;
{n:0}
&lt;p&gt;, reduce: function(obj,out){out.n += obj.a;}}) &lt;br/&gt;
Tue Jan  4 15:28:02 uncaught exception: group command failed: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;not master&quot;, &quot;ok&quot; : 0 }</comment>
                            <comment id="22009" author="mkeranen" created="Mon, 3 Jan 2011 20:57:08 +0000"  >&lt;p&gt;My goal would be to keep the M/R results &lt;em&gt;off&lt;/em&gt; of the master, when performing an ETL aggregation of data into a reporting/analytics store.&lt;/p&gt;</comment>
                            <comment id="21998" author="eliot" created="Mon, 3 Jan 2011 17:55:59 +0000"  >&lt;p&gt;@matt That can cause very weird behavior, especially with replica sets.  one option we can add long term is doing the work on a slave and writing the result to the master.&lt;/p&gt;</comment>
                            <comment id="21997" author="mkeranen" created="Mon, 3 Jan 2011 17:44:17 +0000"  >&lt;p&gt;&amp;gt; for map/reduce, doing &quot;out&quot; to a collection should only work on master &lt;/p&gt;

&lt;p&gt;Would there be benefit to allowing out operations to write into a slave, creating reporting collections from ETL operations that do not affect the master?&lt;/p&gt;

&lt;p&gt;Could such behavior target a separate separate database, keeping the slave database a replica of the master, but allowing high load ETL operations to be isolated on a secondary that cannot be promoted to a master?&lt;/p&gt;</comment>
                            <comment id="21796" author="eliot" created="Fri, 24 Dec 2010 02:03:48 +0000"  >&lt;p&gt;When we do this we should add tests to verify&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;they are not allowed without slave_ok&lt;/li&gt;
	&lt;li&gt;they are allowed with slave_ok&lt;/li&gt;
	&lt;li&gt;for map/reduce, doing &quot;out&quot; to a collection should only work on master&lt;/li&gt;
	&lt;li&gt;out &quot;inline&quot; should work on master or secondary&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>11.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 24 Dec 2010 02:03:48 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            13 years, 6 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>antoine</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>mkeranen</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrp9fj:</customfieldvalue>

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

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

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