<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:36:56 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-55603] Shell read preference behavior is wrong for currentOp</title>
                <link>https://jira.mongodb.org/browse/SERVER-55603</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;First, let&apos;s start a two shard cluster where each shard is a two-node replica set:&lt;/p&gt;
&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;var st = new ShardingTest({shards: 2, rs: {nodes: 2}, mongos: 1});&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;This should result in shardsvr primaries running on ports 20000 and 20002, shardsvr secondaries running on 20001 and 20003, and a mongos running on 20007. Connecting to the mongos &quot;admin&quot; database, we have three ways of running a currentOp:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Directly run the &lt;tt&gt;currentOp&lt;/tt&gt; command, using &lt;tt&gt;db.runCommand({currentOp: 1})&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;Use a &lt;tt&gt;$currentOp&lt;/tt&gt; pipeline, &lt;tt&gt;db.aggregate(&lt;span class=&quot;error&quot;&gt;&amp;#91;\{$currentOp: {}}&amp;#93;&lt;/span&gt;)&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;Use the shell helper, &lt;tt&gt;db.currentOp()&lt;/tt&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&lt;b&gt;Problem #1&lt;/b&gt;: While methods (1) and (2) will target the primaries on 20000 and 20002 as expected, the shell helper method (3) will target the secondaries on 20001 and 20003. I can see from the logs that the shell is sending readPreference mode &quot;secondaryPreferred&quot; to the server, which is not correct.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Problem #2&lt;/b&gt;: If I use the shell to set a &quot;primaryPreferred&quot; readPreference on the session, now both methods (2) and (3) erroneously target the secondary nodes. For example,&lt;/p&gt;
&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;   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;MongoDB Enterprise mongos&amp;gt; db.getSession().getOptions().setReadPreference(&quot;primaryPreferred&quot;)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;MongoDB Enterprise mongos&amp;gt; db.aggregate([{$currentOp: {}}, {$group: {_id: &quot;$host&quot;, count: {$sum: 1}}}]).pretty()&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;{ &quot;_id&quot; : &quot;storchbox:20001&quot;, &quot;count&quot; : 16 }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;{ &quot;_id&quot; : &quot;storchbox:20003&quot;, &quot;count&quot; : 16 }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;I can see from the logs that this operation sends a readPreference of &quot;secondaryPreferred&quot; to mongos, even though the readPreference configured in the shell is &quot;primaryPreferred&quot;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Problem #3&lt;/b&gt;: We should clarify what is supposed to happen when causal consistency is enabled via &lt;tt&gt;db.getMongo().setCausalConsistency()&lt;/tt&gt;. At the moment, methods (1) and (2) will continue to target the primary nodes, but (3) will target the secondaries. This seems likely related to the other observations above, but I wanted to mention it explicitly so test authors know how to handle passthrough suites relying on causal consistency when the test uses currentOp.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1662591">SERVER-55603</key>
            <summary>Shell read preference behavior is wrong for currentOp</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="13203">Gone away</resolution>
                                        <assignee username="katherine.wu@mongodb.com">Katherine Wu</assignee>
                                    <reporter username="david.storch@mongodb.com">David Storch</reporter>
                        <labels>
                            <label>greenerbuild</label>
                    </labels>
                <created>Mon, 29 Mar 2021 20:37:56 +0000</created>
                <updated>Fri, 27 Oct 2023 20:46:09 +0000</updated>
                            <resolved>Fri, 7 May 2021 19:24:33 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3761836" author="katherine.wu" created="Fri, 7 May 2021 19:24:33 +0000"  >&lt;p&gt;Fixed as part of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-47603&quot; title=&quot;Rewrite db.currentOp() shell helper in terms of $currentOp aggregation stage&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-47603&quot;&gt;&lt;del&gt;SERVER-47603&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="3694941" author="david.storch" created="Wed, 31 Mar 2021 20:43:12 +0000"  >&lt;p&gt;The fix from &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-47603&quot; title=&quot;Rewrite db.currentOp() shell helper in terms of $currentOp aggregation stage&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-47603&quot;&gt;&lt;del&gt;SERVER-47603&lt;/del&gt;&lt;/a&gt; has been reverted, so the linked build failure is now resolved as well. During triage of this ticket, we should decide between simply closing this ticket as &quot;Won&apos;t Do&quot;, or looking into whether read preference / causal consistency is implemented correctly in the shell for the $currentOp agg stage and the &lt;tt&gt;db.currentOp()&lt;/tt&gt; helper.&lt;/p&gt;</comment>
                            <comment id="3689982" author="david.storch" created="Mon, 29 Mar 2021 20:42:33 +0000"  >&lt;p&gt;I believe that some of this behavior was introduced as part of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-47603&quot; title=&quot;Rewrite db.currentOp() shell helper in terms of $currentOp aggregation stage&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-47603&quot;&gt;&lt;del&gt;SERVER-47603&lt;/del&gt;&lt;/a&gt;. I think we should likely revert &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-47603&quot; title=&quot;Rewrite db.currentOp() shell helper in terms of $currentOp aggregation stage&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-47603&quot;&gt;&lt;del&gt;SERVER-47603&lt;/del&gt;&lt;/a&gt; as discussed elsewhere. That should resolve the linked build failure. Once the revert is done we should address this ticket, and check whether the problems around currentOp host targeting have gone away&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1318145">SERVER-47603</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 7 May 2021 19:24:33 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 39 weeks, 5 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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 39 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>75.0</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>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>katherine.wu@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hz1t5j:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr36lj:</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_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|hz1fen:</customfieldvalue>

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