<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:22:20 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-72620] $indexStats doesn&apos;t include the &quot;shard&quot; field when run on unsharded collections</title>
                <link>https://jira.mongodb.org/browse/SERVER-72620</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;$indexStats includes the &quot;shard&quot; field on version 4.2 when run on an unsharded collection (correct behavior). However on version 4.4 onwards the &quot;shard&quot; field is missing for unsharded collections even though it should be present.&lt;/p&gt;

&lt;p&gt;See comments for more info.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2227816">SERVER-72620</key>
            <summary>$indexStats doesn&apos;t include the &quot;shard&quot; field when run on unsharded collections</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="13201">Fixed</resolution>
                                        <assignee username="tyler.brock@mongodb.com">Tyler Brock</assignee>
                                    <reporter username="vishnu.kaushik@mongodb.com">Vishnu Kaushik</reporter>
                        <labels>
                    </labels>
                <created>Mon, 9 Jan 2023 15:16:21 +0000</created>
                <updated>Sun, 29 Oct 2023 21:28:32 +0000</updated>
                            <resolved>Sun, 29 Jan 2023 19:02:31 +0000</resolved>
                                    <version>4.4.18</version>
                    <version>5.0.14</version>
                    <version>6.0.4</version>
                    <version>6.2.0-rc6</version>
                                    <fixVersion>4.4.19</fixVersion>
                    <fixVersion>5.0.15</fixVersion>
                    <fixVersion>6.3.0-rc0</fixVersion>
                    <fixVersion>6.0.5</fixVersion>
                                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="5151844" author="xgen-internal-githook" created="Mon, 30 Jan 2023 17:21:45 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Tyler Brock&apos;, &apos;email&apos;: &apos;tyler.brock@gmail.com&apos;, &apos;username&apos;: &apos;TylerBrock&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-72620&quot; title=&quot;$indexStats doesn&amp;#39;t include the &amp;quot;shard&amp;quot; field when run on unsharded collections&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-72620&quot;&gt;&lt;del&gt;SERVER-72620&lt;/del&gt;&lt;/a&gt; ensure shard added to $indexStats for unsharded collections&lt;br/&gt;
Branch: v4.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/942e2e9541f97448538e603c0fb14967d577e633&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/942e2e9541f97448538e603c0fb14967d577e633&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5151716" author="xgen-internal-githook" created="Mon, 30 Jan 2023 16:49:39 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Tyler Brock&apos;, &apos;email&apos;: &apos;tyler.brock@gmail.com&apos;, &apos;username&apos;: &apos;TylerBrock&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-72620&quot; title=&quot;$indexStats doesn&amp;#39;t include the &amp;quot;shard&amp;quot; field when run on unsharded collections&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-72620&quot;&gt;&lt;del&gt;SERVER-72620&lt;/del&gt;&lt;/a&gt; ensure shard added to $indexStats for unsharded collections&lt;br/&gt;
Branch: v6.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/909bf6415431b6260dec1baedcd799c27626039c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/909bf6415431b6260dec1baedcd799c27626039c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5151668" author="xgen-internal-githook" created="Mon, 30 Jan 2023 16:38:04 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Tyler Brock&apos;, &apos;email&apos;: &apos;tyler.brock@gmail.com&apos;, &apos;username&apos;: &apos;TylerBrock&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-72620&quot; title=&quot;$indexStats doesn&amp;#39;t include the &amp;quot;shard&amp;quot; field when run on unsharded collections&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-72620&quot;&gt;&lt;del&gt;SERVER-72620&lt;/del&gt;&lt;/a&gt; ensure shard added to $indexStats for unsharded collections&lt;br/&gt;
Branch: v5.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/58a2c8137cc2abfdf2bf274d2cc9aee645f9f519&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/58a2c8137cc2abfdf2bf274d2cc9aee645f9f519&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5149658" author="JIRAUSER1269186" created="Sun, 29 Jan 2023 19:02:32 +0000"  >&lt;p&gt;Fixes behavior to reflect original (documented) behavior of $indexStats to include the shard name in a sharded context even on unsharded collections.&lt;/p&gt;</comment>
                            <comment id="5149627" author="xgen-internal-githook" created="Sun, 29 Jan 2023 18:42:23 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Tyler Brock&apos;, &apos;email&apos;: &apos;tyler.brock@gmail.com&apos;, &apos;username&apos;: &apos;TylerBrock&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-72620&quot; title=&quot;$indexStats doesn&amp;#39;t include the &amp;quot;shard&amp;quot; field when run on unsharded collections&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-72620&quot;&gt;&lt;del&gt;SERVER-72620&lt;/del&gt;&lt;/a&gt; ensure shard added to $indexStats for unsharded collections&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/f6897efb24aea4d923b6646b2379fa64dd041480&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/f6897efb24aea4d923b6646b2379fa64dd041480&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5099867" author="vishnu.kaushik" created="Mon, 9 Jan 2023 15:21:02 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=tyler.brock%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;tyler.brock@mongodb.com&quot;&gt;tyler.brock@mongodb.com&lt;/a&gt;&apos;s comment:&lt;/p&gt;

&lt;p&gt;It looks like &lt;tt&gt;getIndexStats()&lt;/tt&gt; determines whether or not to include the shard name info based on the addShardName param which it gets from the expression context&apos;s &lt;tt&gt;fromMongos&lt;/tt&gt; bool. So the question is what is setting the &lt;tt&gt;fromMongos&lt;/tt&gt; bool...&lt;br/&gt;
I think this is because &lt;tt&gt;ClusterAggregate::runAggregate&lt;/tt&gt; makes an ExpressionContext with fromMongos set to a default of false and switches on TargetingPolicy. When that targeting policy is:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;kPassthrough -&amp;gt; sends the command to the primary shard without modifying default fromMongos&lt;/li&gt;
	&lt;li&gt;kAnyShard -&amp;gt; eventually calls into createCommandForMergingShard which sets fromMongos to true&lt;br/&gt;
This seems reasonable since if the collection isn&apos;t sharded you know where the index lives -&amp;gt; the primary shard &amp;#8211; the documentation can probably be clarified here.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;On the other hand, the server ticket that added the code seems to indicate it should always be included however when run on a sharded cluster: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-44915&quot; title=&quot;Extend $indexStats output to include full index options and shard name&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-44915&quot;&gt;&lt;del&gt;SERVER-44915&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;&quot;Output documents generated for indexes on sharding enabled node started with --shardsvr should contain the shardId of the shard that generated the document in a new shard field&quot;&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;So it would seem that we&apos;ve got a bug, nice spot!&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1031548">SERVER-44915</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25134"><![CDATA[Sharding NYC]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25041"><![CDATA[v6.2]]></customfieldvalue>
    <customfieldvalue key="23470"><![CDATA[v6.0]]></customfieldvalue>
    <customfieldvalue key="21777"><![CDATA[v5.0]]></customfieldvalue>
    <customfieldvalue key="18953"><![CDATA[v4.4]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 13 Jan 2023 03:08:21 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 1 week, 2 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_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </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>
                            1 year, 1 week, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>151.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>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>tyler.brock@mongodb.com</customfieldvalue>
            <customfieldvalue>vishnu.kaushik@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i1pp53:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i18888:</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_22250" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Special Downgrade Instructions Required</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23343"><![CDATA[Not Needed]]></customfieldvalue>

                        </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|i1pbaf:</customfieldvalue>

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