<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:16:34 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-70592] Have clusterQueryWithoutShardKey apply the sort order if findAndModify supplies one</title>
                <link>https://jira.mongodb.org/browse/SERVER-70592</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description></description>
                <environment></environment>
        <key id="2159551">SERVER-70592</key>
            <summary>Have clusterQueryWithoutShardKey apply the sort order if findAndModify supplies one</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="jason.zhang@mongodb.com">Jason Zhang</assignee>
                                    <reporter username="jason.zhang@mongodb.com">Jason Zhang</reporter>
                        <labels>
                    </labels>
                <created>Fri, 14 Oct 2022 20:11:52 +0000</created>
                <updated>Sun, 29 Oct 2023 21:31:52 +0000</updated>
                            <resolved>Mon, 20 Mar 2023 19:52:33 +0000</resolved>
                                                    <fixVersion>7.0.0-rc0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="5286142" author="xgen-internal-githook" created="Mon, 20 Mar 2023 19:47:06 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Jason Zhang&apos;, &apos;email&apos;: &apos;jason.zhang@mongodb.com&apos;, &apos;username&apos;: &apos;jz1242&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-70592&quot; title=&quot;Have clusterQueryWithoutShardKey apply the sort order if findAndModify supplies one&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-70592&quot;&gt;&lt;del&gt;SERVER-70592&lt;/del&gt;&lt;/a&gt; Have clusterQueryWithoutShardKey apply the sort order if findAndModify supplies one&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/35dd182c3e4029465a95000409f575cf781d20b9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/35dd182c3e4029465a95000409f575cf781d20b9&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5094385" author="JIRAUSER1253438" created="Thu, 5 Jan 2023 22:12:12 +0000"  >&lt;p&gt;Chatted with Nick on Query, came up with an approach:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Use &lt;a href=&quot;https://github.com/10gen/mongo/blob/1f0059a312ed906e78db95b246e15359c83db2ae/src/mongo/s/commands/cluster_query_without_shard_key_cmd.cpp#L166-L171&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;results from ARS&lt;/a&gt; to construct RemoteCursors, similar to how its done &lt;a href=&quot;https://github.com/10gen/mongo/blob/1f0059a312ed906e78db95b246e15359c83db2ae/src/mongo/s/query/establish_cursors.cpp#L187-L191&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
	&lt;li&gt;Use the RemoteCursors to construct a &lt;a href=&quot;https://github.com/10gen/mongo/blob/1f0059a312ed906e78db95b246e15359c83db2ae/src/mongo/s/query/async_results_merger_params.idl#L66-L99&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ARMParams&lt;/a&gt; which can be used to construct an &lt;a href=&quot;https://github.com/10gen/mongo/blob/1f0059a312ed906e78db95b246e15359c83db2ae/src/mongo/s/query/async_results_merger.h#L101-L103&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AsycResultsMerger&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Get sorted result from &lt;a href=&quot;https://github.com/10gen/mongo/blob/1f0059a312ed906e78db95b246e15359c83db2ae/src/mongo/s/query/async_results_merger.cpp#L351-L368&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AsyncResultsMerger::nextReady()&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Alternative approach:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Project on $sortKey like the ARM does, and directly call the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1eb33d31a32bb7d1a1a18e07c78239b90a9dd5d3/src/mongo/s/query/async_results_merger.cpp#L948-L955&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;comparator&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="5091218" author="JIRAUSER1253438" created="Wed, 4 Jan 2023 21:13:44 +0000"  >&lt;p&gt;Investigated approach #2 today, the ARM seems pretty deeply tied with the implementation of cluster_find &amp;amp; cluster_aggregation. Doing a bit more final investigation to see if there&apos;s a way to isolate the ARM sorting layer, but I&apos;ll likely pursue option #1. There might be advantages to setting returning the $sortKey value from each shard along with the target document as it would allow doing a direct binary comparison between documents. &lt;/p&gt;</comment>
                            <comment id="5089856" author="JIRAUSER1253438" created="Wed, 4 Jan 2023 14:48:06 +0000"  >&lt;p&gt;Currently, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1eb33d31a32bb7d1a1a18e07c78239b90a9dd5d3/src/mongo/s/query/async_results_merger.cpp#L102-L143&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AsyncResultsMerger&lt;/a&gt; gathers and sorts results from open cursors in a multi-shard find command or aggregation.&lt;/p&gt;

&lt;p&gt;In the current implementation of _clusterQueryWithoutShardKey, we &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1eb33d31a32bb7d1a1a18e07c78239b90a9dd5d3/src/mongo/s/commands/cluster_query_without_shard_key_cmd.cpp#L173-L185&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;collect a set of matching documents from an ARS and select one as the target doc. &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two options come to mind here:&lt;br/&gt;
1) Use the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1eb33d31a32bb7d1a1a18e07c78239b90a9dd5d3/src/mongo/s/query/async_results_merger.cpp#L948-L955&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;internal comparator&lt;/a&gt; in AsyncResultsMerger to compare the set of matching documents by sort key&lt;br/&gt;
2) Layer the AsycnResultsMerger on top of _clusterQueryWithoutShardKey&apos;s ARS with a merge cursors stage using &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1eb33d31a32bb7d1a1a18e07c78239b90a9dd5d3/src/mongo/db/pipeline/sharded_agg_helpers.cpp#L1349-L1358&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5088380" author="JIRAUSER1253438" created="Tue, 3 Jan 2023 21:45:40 +0000"  >{sort: true}
&lt;p&gt; can only be set for findAndModify commands (update/delete do not support this field). If a collation is spec&apos;d in this findAndModify command, use it during the final sorting as well.&lt;/p&gt;</comment>
                            <comment id="5088322" author="JIRAUSER1253438" created="Tue, 3 Jan 2023 21:20:19 +0000"  >&lt;p&gt;High level approach:&lt;/p&gt;

&lt;p&gt;In _clusterQueryWithoutShardKey, &lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/10gen/mongo/blob/46416b3fe7a9affa2cf49c7ed07ca6a52b5dfbec/src/mongo/s/commands/cluster_query_without_shard_key_cmd.cpp#L114-L145&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Capture value of sort field&lt;/a&gt;, if set.&lt;/li&gt;
	&lt;li&gt;Append &lt;a href=&quot;https://github.com/10gen/mongo/blob/46416b3fe7a9affa2cf49c7ed07ca6a52b5dfbec/src/mongo/s/commands/cluster_query_without_shard_key_cmd.cpp#L83-L86&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;$sort to query aggregation command&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Project on &lt;a href=&quot;https://github.com/10gen/mongo/blob/46416b3fe7a9affa2cf49c7ed07ca6a52b5dfbec/src/mongo/s/commands/cluster_query_without_shard_key_cmd.cpp#L86&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;_id &amp;amp; sort fields&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/10gen/mongo/blob/46416b3fe7a9affa2cf49c7ed07ca6a52b5dfbec/src/mongo/s/commands/cluster_query_without_shard_key_cmd.cpp#L179&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Sort between shard responses here&lt;/a&gt; and assign winning document as the target doc.&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>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 3 Jan 2023 21:20:19 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        46 weeks, 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-1632</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>
                            46 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>jason.zhang@mongodb.com</customfieldvalue>
            <customfieldvalue>sanika.phanse@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i1e5cf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hxiabj:i</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="6354">Sharding 2022-12-12</customfieldvalue>
    <customfieldvalue id="6356">Sharding NYC 2023-01-09</customfieldvalue>
    <customfieldvalue id="6867">Sharding NYC 2023-02-20</customfieldvalue>
    <customfieldvalue id="6868">Sharding NYC 2023-03-06</customfieldvalue>
    <customfieldvalue id="6869">Sharding NYC 2023-03-20</customfieldvalue>
    <customfieldvalue id="7157">Sharding NYC 2023-04-03</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|i1drhr:</customfieldvalue>

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