<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:46:13 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-81335] Query operations that avoid going through the network when a shard is targeting only itself should create a fresh operation context</title>
                <link>https://jira.mongodb.org/browse/SERVER-81335</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Trying to keep this ticket generic, although I believe that most of the related issues / BF tickets are related to the optimization performed in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-77427&quot; title=&quot;Avoid going through the network when a shard is targeting only itself for a $lookup subpipeline&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-77427&quot;&gt;&lt;del&gt;SERVER-77427&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;ins&gt;Why didn&apos;t we see these errors before?&lt;/ins&gt;&lt;/b&gt;&lt;br/&gt;
Mostly due to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-81007&quot; title=&quot;FSM workloads no longer fail when $config.states functions throw exceptions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-81007&quot;&gt;&lt;del&gt;SERVER-81007&lt;/del&gt;&lt;/a&gt;. The FSM framework was swallowing some exceptions. This was addressed in 7.1.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;ins&gt;Affected versions&lt;/ins&gt;&lt;/b&gt;&lt;br/&gt;
The bug that caused those errors to be shallowed&#160; (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-79735&quot; title=&quot;Bulk convert the rest of the jstest corpus to use modules&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-79735&quot;&gt;&lt;del&gt;SERVER-79735&lt;/del&gt;&lt;/a&gt;) was introduced on 7.1.&#160; Thus, I would expect that if any previous version was suffering of these failures at least our testing coverage would have caught them. What I believe is the conflicting commit (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-77427&quot; title=&quot;Avoid going through the network when a shard is targeting only itself for a $lookup subpipeline&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-77427&quot;&gt;&lt;del&gt;SERVER-77427&lt;/del&gt;&lt;/a&gt;) was introduced on 7.1, which matches with the timeline.&lt;/p&gt;

&lt;p&gt;&#160;&lt;br/&gt;
&lt;b&gt;&lt;ins&gt;About the issue&lt;/ins&gt;&lt;/b&gt;&lt;br/&gt;
In the query framework we have &lt;a href=&quot;https://github.com/mongodb/mongo/blob/c556d80f28d51179d78b3f6b3f1ffb53b676b0b2/src/mongo/db/pipeline/sharded_agg_helpers.cpp#L1828-L1833&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;at least one place&lt;/a&gt; in which if we detect that an operation that was going to be sent through the network is just involving the current shard, we end up executing it locally. This local execution is performed without creating a fresh operation context (i.e. reusing the existing one), which could be problematic, specially for components like the &lt;tt&gt;OperationShardingState&lt;/tt&gt; that assumes that a pair of &lt;tt&gt;&amp;lt;OpCtx, nss&amp;gt;&lt;/tt&gt; can only be associated with one shard version. Note that this is just an example but we could have other components doing similar assumptions.&lt;/p&gt;

&lt;p&gt;The problematic interleaving is the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Router sends an operation with &lt;tt&gt;SV1&lt;/tt&gt; and &lt;tt&gt;nss&lt;/tt&gt; on a certain shard.&lt;/li&gt;
	&lt;li&gt;Shard start its execution, registering the &lt;tt&gt;&amp;lt;OpCtx, nss&amp;gt;&lt;/tt&gt; with &lt;tt&gt;SV1&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;A DDL operation bump the shardVersion of that shard to &lt;tt&gt;SV2&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;The shard continues the execution of the operation, and it reaches a point in which in theory it has to send a request to a set of shards. This set only includes itself, so it ends up performing a direct execution of the command.&lt;/li&gt;
	&lt;li&gt;We try to register the pair &lt;tt&gt;&amp;lt;OpCtx, nss&amp;gt;&lt;/tt&gt; with &lt;tt&gt;SV2&lt;/tt&gt; on the &lt;tt&gt;OperationShardingState&lt;/tt&gt; but because of 2. we end up failing.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&lt;b&gt;Update&lt;/b&gt;&lt;br/&gt;
it even looks like we don&apos;t really need to have a bump of the shard version (step 3): some kind of query operations, I believe that the ones that use &lt;tt&gt;$mergeCursors&lt;/tt&gt;, initially attach &lt;tt&gt;ChunkVersion::IGNORED&lt;/tt&gt;, so if that operation needs to perform some targeting and end ups deciding to perform a local execution it, it will also hit the same failure (see BF-30079).&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;ins&gt;How should we fix it?&lt;/ins&gt;&lt;/b&gt;&lt;br/&gt;
I asked about the semantics of command re-entrance to service-arch. They mentioned that ideally we should create a fresh operation context in this situations, to avoid hitting assumptions like the one explained above.&lt;/p&gt;

&lt;p&gt;Another thing we could consider is reverting &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-77427&quot; title=&quot;Avoid going through the network when a shard is targeting only itself for a $lookup subpipeline&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-77427&quot;&gt;&lt;del&gt;SERVER-77427&lt;/del&gt;&lt;/a&gt; if it ends up being the root cause of the failures.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2448811">SERVER-81335</key>
            <summary>Query operations that avoid going through the network when a shard is targeting only itself should create a fresh operation context</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="1" iconUrl="https://jira.mongodb.org/images/icons/statuses/open.png" description="">Open</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="mihai.andrei@mongodb.com">Mihai Andrei</assignee>
                                    <reporter username="sergi.mateo-bellido@mongodb.com">Sergi Mateo Bellido</reporter>
                        <labels>
                    </labels>
                <created>Fri, 22 Sep 2023 07:00:09 +0000</created>
                <updated>Fri, 2 Feb 2024 15:11:34 +0000</updated>
                                                                                                <votes>0</votes>
                                    <watches>15</watches>
                                                                                                                <comments>
                            <comment id="5881336" author="JIRAUSER1270969" created="Wed, 15 Nov 2023 09:14:39 +0000"  >&lt;p&gt;Currently the main way to test this is $lookup.&lt;br/&gt;
However, currently it doesn&apos;t support unsplittable collections, so I am blocking this ticket until we do &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-79580&quot; title=&quot;Remove HostTypeRequirement::kPrimaryShard from $lookup&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-79580&quot;&gt;&lt;del&gt;SERVER-79580&lt;/del&gt;&lt;/a&gt;.&lt;br/&gt;
It will give us good test coverage for potential solutions.&lt;/p&gt;</comment>
                            <comment id="5733897" author="xgen-internal-githook" created="Wed, 27 Sep 2023 10:26:34 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Ivan Fefer&apos;, &apos;email&apos;: &apos;ivan.fefer@mongodb.com&apos;, &apos;username&apos;: &apos;Fefer-Ivan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-81335&quot; title=&quot;Query operations that avoid going through the network when a shard is targeting only itself should create a fresh operation context&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-81335&quot;&gt;SERVER-81335&lt;/a&gt; Fallback to remote read if local read for sub pipeline fails with IllegalChangeToExpectedShardVersion&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/b5330fcbc5989e6f7750bba166379ea75d47502f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/b5330fcbc5989e6f7750bba166379ea75d47502f&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5733720" author="JIRAUSER1270969" created="Wed, 27 Sep 2023 08:10:02 +0000"  >&lt;p&gt;Revert is merged to 7.1 branch: &lt;a href=&quot;https://github.com/mongodb/mongo/commit/aae297113407b219885bfe44f25a1fb377e04557&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/aae297113407b219885bfe44f25a1fb377e04557&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The ticket remains open, so we can properly fix this issue in master for the future releases.&lt;/p&gt;</comment>
                            <comment id="5733083" author="JIRAUSER1274113" created="Tue, 26 Sep 2023 22:32:17 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ivan.fefer%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;ivan.fefer@mongodb.com&quot;&gt;ivan.fefer@mongodb.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;What is the actual status of this one? Do you still need to merge the change/revert to the 7.1 branch?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="2406423">SERVER-79580</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2495447">SERVER-83056</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="2446778">SERVER-81234</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2446779">SERVER-81235</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                                                <inwardlinks description="is caused by">
                                        <issuelink>
            <issuekey id="2349361">SERVER-77427</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2440248">SERVER-81007</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>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25125"><![CDATA[Query Execution]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="27038"><![CDATA[v7.3]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 25 Sep 2023 18:41:39 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        12 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-83056'>SERVER-83056</a></s>, <s><a href='https://jira.mongodb.org/browse/SERVER-79580'>SERVER-79580</a></s>]]></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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-3229</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>mihai.andrei@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            12 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>160.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>ivan.fefer@mongodb.com</customfieldvalue>
            <customfieldvalue>maria.prinus@mongodb.com</customfieldvalue>
            <customfieldvalue>mihai.andrei@mongodb.com</customfieldvalue>
            <customfieldvalue>sergi.mateo-bellido@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i2roa7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i29md0:</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="7251">QE 2023-10-02</customfieldvalue>
    <customfieldvalue id="7254">QE 2023-10-16</customfieldvalue>
    <customfieldvalue id="8062">QE 2024-02-19</customfieldvalue>

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

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