<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:42:50 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-36349] Handle the ShardingOperationFailedStatus in the OperationShardingState destructor when the OperationContext is not created in a ServiceEntryPoint</title>
                <link>https://jira.mongodb.org/browse/SERVER-36349</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Whenever an OperationContext is created, an OperationShardingState is created &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/s/operation_sharding_state.cpp#L39&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;as a decoration on the OperationContext&lt;/a&gt;.  When it&apos;s created through the regular process of a ServiceEntryPoint, a &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/service_entry_point_common.cpp#L841&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ScopedOperationCompletionShardingAction is created&lt;/a&gt; that will go out of scope at the end of ServiceEntryPoint::execCommandDatabase(). When an OperationContext is created  &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/logical_session_cache_impl.cpp#L281&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;outside of the regular process of a ServiceEntryPoint&lt;/a&gt;, a ScopedOperationCompletionShardingAction is not created.&lt;/p&gt;

&lt;p&gt;If an exception occurs during a WriteOp that matches &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/ops/write_ops_exec.cpp#L237&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;StaleConfigInfo or CannotImplicitlyCreateCollectionInfo&lt;/a&gt;, the OperationShardingState will &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/s/operation_sharding_state.cpp#L181&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;set a failed status in an error Status member variable&lt;/a&gt;. This Status is expected to be handled and reset by the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/s/scoped_operation_completion_sharding_actions.cpp#L62&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;destructor of ScopedOperationCompletionShardingActions&lt;/a&gt;. That is currently the only place where the Status could be reset.&lt;/p&gt;

&lt;p&gt;When the OperationShardingState is destructed, an invariant exists that asserts that the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4dcebf9c4834bb65d1676f3aaa2a04e4f10967f0/src/mongo/db/s/operation_sharding_state.cpp#L55&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;error Status member variable in OperationShardingState has been reset&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In the case that an OperationContext is created outside of the ServiceEntryPoint codepath, a ScopedOperationCompletionShardingActions object will never exist to reset the error Status member variable. Upon destruction of the OperationContext, the destructor for the OperationShardingState will be called as well. If there was ever a StaleConfig or CannotImplicitlyCreateCollection status/exception, in a WriteOp, during the lifetime of the OperationContext, the destructor will trip the invariant.&lt;/p&gt;

&lt;p&gt;We should either relax the invariant, or think of other appropriate places to reset the OperationShardingState error Status member variable.&lt;/p&gt;</description>
                <environment></environment>
        <key id="579540">SERVER-36349</key>
            <summary>Handle the ShardingOperationFailedStatus in the OperationShardingState destructor when the OperationContext is not created in a ServiceEntryPoint</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="blake.oler@mongodb.com">Blake Oler</assignee>
                                    <reporter username="cheahuychou.mao@mongodb.com">Cheahuychou Mao</reporter>
                        <labels>
                    </labels>
                <created>Mon, 30 Jul 2018 15:20:50 +0000</created>
                <updated>Sun, 29 Oct 2023 22:29:26 +0000</updated>
                            <resolved>Mon, 3 Dec 2018 21:05:49 +0000</resolved>
                                    <version>4.0.0</version>
                    <version>4.1.1</version>
                                    <fixVersion>4.0.5</fixVersion>
                    <fixVersion>4.1.6</fixVersion>
                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="2086322" author="xgen-internal-githook" created="Mon, 10 Dec 2018 21:38:34 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Blake Oler&apos;, &apos;email&apos;: &apos;blake.oler@mongodb.com&apos;, &apos;username&apos;: &apos;BlakeIsBlake&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-36349&quot; title=&quot;Handle the ShardingOperationFailedStatus in the OperationShardingState destructor when the OperationContext is not created in a ServiceEntryPoint&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-36349&quot;&gt;&lt;del&gt;SERVER-36349&lt;/del&gt;&lt;/a&gt; Prevent ClusterWrite errors from affecting the OperationShardingState&apos;s error handling&lt;/p&gt;

&lt;p&gt;(cherry picked from commit be673d00e71fe975fe9fe934ce719ff9d27a2712)&lt;br/&gt;
Branch: v4.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/55fe7608091791ff5b46de3c15fbf368268128f4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/55fe7608091791ff5b46de3c15fbf368268128f4&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2078985" author="xgen-internal-githook" created="Mon, 3 Dec 2018 19:58:43 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Blake Oler&apos;, &apos;email&apos;: &apos;blake.oler@mongodb.com&apos;, &apos;username&apos;: &apos;BlakeIsBlake&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-36349&quot; title=&quot;Handle the ShardingOperationFailedStatus in the OperationShardingState destructor when the OperationContext is not created in a ServiceEntryPoint&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-36349&quot;&gt;&lt;del&gt;SERVER-36349&lt;/del&gt;&lt;/a&gt; Prevent ClusterWrite errors from affecting the OperationShardingState&apos;s error handling&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/be673d00e71fe975fe9fe934ce719ff9d27a2712&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/be673d00e71fe975fe9fe934ce719ff9d27a2712&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2060210" author="blake.oler" created="Tue, 13 Nov 2018 16:13:26 +0000"  >&lt;p&gt;In the logical session refresh, the opCtx for the ClusterWriter will &lt;em&gt;never&lt;/em&gt; receive a &lt;tt&gt;ScopedOperationCompletionShardingAction&lt;/tt&gt; entry. This is because when the &lt;tt&gt;ScopedOperationCompletionShardingAction&lt;/tt&gt; code was written, it was under the assumption that we will always be writing through the command loop. The logical session cache refresh function isn&apos;t in the command loop.&lt;/p&gt;

&lt;p&gt;Whether or not the opCtx created can ever actually receive the &lt;tt&gt;StaleConfigInfo&lt;/tt&gt; due to the ARS&apos;s asynchronicity is outside of the scope of my current understanding of how the ARS works. However, it still stands that if the logical session cache refresh receives a &lt;tt&gt;StaleConfigInfo&lt;/tt&gt; error, it will not need to act on it.&lt;/p&gt;</comment>
                            <comment id="2059864" author="kaloian.manassiev" created="Tue, 13 Nov 2018 12:02:06 +0000"  >&lt;p&gt;Just for my understanding, how does the OpCtx on which the ClusterWriter runs get a &lt;tt&gt;ScopedOperationCompletionShardingAction&lt;/tt&gt; entry on it?&lt;/p&gt;

&lt;p&gt;The cluster writer should be using one OpCtx and the ARS (which is async), meaning the StaleConfigInfo should be happening on a different thread/OpCtx.&lt;/p&gt;</comment>
                            <comment id="2059058" author="renctan" created="Mon, 12 Nov 2018 18:17:02 +0000"  >&lt;p&gt;Approach sounds good to me.&lt;/p&gt;</comment>
                            <comment id="2059018" author="esha.maharishi@10gen.com" created="Mon, 12 Nov 2018 17:51:00 +0000"  >&lt;p&gt;Sounds fine to me, as long as the logical session cache refresh really does not need to take action on StaleConfig or CannotImplicitlyCreateCollection, which I don&apos;t know enough about to say.&lt;/p&gt;</comment>
                            <comment id="2058983" author="blake.oler" created="Mon, 12 Nov 2018 17:29:27 +0000"  >&lt;p&gt;The logical session cache&apos;s refresh is the only place where both create our own opCtx, and use the ClusterWriter from within a mongod. This means that the refresh is currently the only place where we could receive these errors outside of a service entry point&apos;s command loop.&lt;/p&gt;

&lt;p&gt;This particular invariant in the &lt;tt&gt;OperationShardingState&lt;/tt&gt; asserts that we deal with both &lt;tt&gt;StaleConfigInfo&lt;/tt&gt; and &lt;tt&gt;CannotImplicitlyCreateCollectionInfo&lt;/tt&gt;&#160;errors. These are necessary to act upon during a command loop. However, we do not intend to deal with either of these errors if they bubble up directly from the refresh. If we receive a&#160;&lt;tt&gt;StaleConfigInfo&lt;/tt&gt; error during using the ClusterWriter, we will simply ignore these errors and retarget on the next refresh cycle. If we receive a&#160;&lt;tt&gt;CannotImplicitlyCreateCollectionInfo&lt;/tt&gt; error, then we will recreate the collection properly on the next refresh cycle.&lt;/p&gt;

&lt;p&gt;Because we don&apos;t care about acting upon these errors, we have a quick fix solution &amp;#8211; create an ON_BLOCK_EXIT function that will directly clear any erroneous status from the &lt;tt&gt;OperationShardingState&lt;/tt&gt; upon exit from the refresh. Since the &lt;tt&gt;OperationShardingState&lt;/tt&gt; that&apos;s throwing the invariant is created by and directly attached to our created opCtx, this will have no greater impact on operations outside of the refresh itself. &lt;/p&gt;

&lt;p&gt;Looking to either &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.maharishi&quot; class=&quot;user-hover&quot; rel=&quot;esha.maharishi&quot;&gt;esha.maharishi&lt;/a&gt; or &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=renctan&quot; class=&quot;user-hover&quot; rel=&quot;renctan&quot;&gt;renctan&lt;/a&gt; to LGTM this solution (since Misha is out this week)&lt;/p&gt;</comment>
                            <comment id="2016700" author="blake.oler" created="Thu, 27 Sep 2018 18:25:27 +0000"  >&lt;p&gt;Pulling this out of the Logical Sessions Refactor epic, because the error is not unique to the Logical Session Cache. I am also putting this back into Needs Scheduling so that the Sharding team can assess the severity of this bug.&lt;/p&gt;</comment>
                            <comment id="1986680" author="misha.tyulenev" created="Mon, 27 Aug 2018 17:12:26 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=greg.mckeon&quot; class=&quot;user-hover&quot; rel=&quot;greg.mckeon&quot;&gt;greg.mckeon&lt;/a&gt; yes, this and all logical sessions cache issues going to this epic. Updated the ticket. thanks!&lt;/p&gt;</comment>
                            <comment id="1986494" author="greg.mckeon" created="Mon, 27 Aug 2018 15:30:42 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=misha.tyulenev&quot; class=&quot;user-hover&quot; rel=&quot;misha.tyulenev&quot;&gt;misha.tyulenev&lt;/a&gt; does this belong in your logical sessions refactor epic?&lt;/p&gt;</comment>
                            <comment id="1965041" author="greg.mckeon" created="Fri, 3 Aug 2018 15:43:23 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=misha.tyulenev&quot; class=&quot;user-hover&quot; rel=&quot;misha.tyulenev&quot;&gt;misha.tyulenev&lt;/a&gt; can you talk with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=cheahuychou.mao&quot; class=&quot;user-hover&quot; rel=&quot;cheahuychou.mao&quot;&gt;cheahuychou.mao&lt;/a&gt; about how you want to fix this?&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>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>11.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="15640"><![CDATA[v4.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>Fri, 3 Aug 2018 15:43:23 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 9 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_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>
                            5 years, 9 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>57.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>blake.oler@mongodb.com</customfieldvalue>
            <customfieldvalue>cheahuychou.mao@mongodb.com</customfieldvalue>
            <customfieldvalue>esha.maharishi@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>greg.mckeon@mongodb.com</customfieldvalue>
            <customfieldvalue>kaloian.manassiev@mongodb.com</customfieldvalue>
            <customfieldvalue>misha.tyulenev@mongodb.com</customfieldvalue>
            <customfieldvalue>randolph@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu3zzz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htuntb:</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="2540">Sharding 2018-11-05</customfieldvalue>
    <customfieldvalue id="2581">Sharding 2018-11-19</customfieldvalue>
    <customfieldvalue id="2611">Sharding 2018-12-03</customfieldvalue>
    <customfieldvalue id="2639">Sharding 2018-12-17</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|hu3m9b:</customfieldvalue>

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