<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:44:00 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-58246] Commands flagged as &apos;never allowed on secondaries&apos; can proceed running after a node steps down from primary</title>
                <link>https://jira.mongodb.org/browse/SERVER-58246</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Consider a command flagged as &lt;a href=&quot;https://github.com/mongodb/mongo/blob/110a58f2ece4fd1efaa93ccf552883fef047a00b/src/mongo/db/commands.h#L353&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&apos;kNever&apos; allowed on secondaries&lt;/a&gt;. &lt;br/&gt;
 Before calling the run() of the command, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/110a58f2ece4fd1efaa93ccf552883fef047a00b/src/mongo/db/service_entry_point_common.cpp#L1488&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here it is checked that the command is allowed to run given this node repl state&lt;/a&gt;. However, the node could transition to secondary once we are past this check and continue running the command.&lt;/p&gt;

&lt;p&gt;There are several instances of commands that call &apos;opCtx-&amp;gt;setAlwaysInterruptAtStepDownOrUp();&apos; at the begining of their run() (e.g. &lt;a href=&quot;https://github.com/mongodb/mongo/blob/110a58f2ece4fd1efaa93ccf552883fef047a00b/src/mongo/db/s/shardsvr_drop_collection_command.cpp#L80&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;), so that they can get interrupted should the node transition to secondary. However, the node could already have transitioned to secondary after passing the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/110a58f2ece4fd1efaa93ccf552883fef047a00b/src/mongo/db/service_entry_point_common.cpp#L1488&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;commandCanRunHere&lt;/a&gt; check, but before marking the opCtx as &apos;setAlwaysInterruptAtStepDownOrUp&apos;. In this case, the command would proceed running on a secondary.&lt;/p&gt;

&lt;p&gt;It could be worth to atomically check that the command is allowed to run on this node and mark the opCtx as killable on stepdown in the prologue.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1807704">SERVER-58246</key>
            <summary>Commands flagged as &apos;never allowed on secondaries&apos; can proceed running after a node steps down from primary</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="jordi.serra-torrens@mongodb.com">Jordi Serra Torrens</assignee>
                                    <reporter username="jordi.serra-torrens@mongodb.com">Jordi Serra Torrens</reporter>
                        <labels>
                    </labels>
                <created>Fri, 2 Jul 2021 15:44:31 +0000</created>
                <updated>Tue, 10 May 2022 15:27:39 +0000</updated>
                            <resolved>Thu, 28 Oct 2021 10:53:15 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="4153976" author="JIRAUSER1257318" created="Thu, 28 Oct 2021 10:52:52 +0000"  >&lt;p&gt;As per George&apos;s comment above, closing this ticket as &apos;won&apos;t do&apos;.&lt;br/&gt;
I&apos;ve created &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-61066&quot; title=&quot;Make shardsvr DDL commands check primary status after marking opCtx as interruptible&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-61066&quot;&gt;&lt;del&gt;SERVER-61066&lt;/del&gt;&lt;/a&gt; to handle this situation in an ad-hoc basis to resolve the two BF that were linked to this ticket.&lt;/p&gt;</comment>
                            <comment id="4122145" author="george.wangensteen" created="Wed, 13 Oct 2021 17:24:49 +0000"  >&lt;p&gt;I&apos;ve spent some time looking into this issue, and, more generally, the proliferation of OperationContext::setAlwaysInterruptAtStepDownOrUp in the codebase and in sharding-commands, which I&apos;ve spoken with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jordi.serra-torrens&quot; class=&quot;user-hover&quot; rel=&quot;jordi.serra-torrens&quot;&gt;jordi.serra-torrens&lt;/a&gt;&#160;about. I am looking into how we might provide a better mechanism to address the underlying pain of ensuring interruption for certain commands on replication state change, but unfortunately this ticket is not feasible for us right now.&#160;&lt;/p&gt;

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

&lt;p&gt;The current commandCanRunHere check in the command-prologue referred to in the description is provided as a courtesy and is best-effort; there is no guarantee (and never has been) that commands that mark themselves as only runnable on primaries will actually be on a primary when their ::run function begins. Providing a strong-check would require holding the RSTL for the duration of the time one must run on the primary, or at the least holding it while checking the current replication state and setting the interruption-request flag on the operation context (although even this should not be necessary:&#160;operations are generally interrupted if they had (ever, in their lifetime) taken the RSTL in a mode conflicting with writes - and this is how all operations were interrupted due to in incompatible repl state change before this flag was added). Acquiring the global lock in this way in the command prologue is undesirable and has caused issues in the past; we&apos;d like to avoid doing so. In the past, commands would simply error out/be interrupted later in their lifecycles, after they had determined they would actually need to perform an action incompatible with being on a secondary and therefore taken the RSTL in mode at least IX. I am currently investigating why this approach is not meeting the needs of some code/why the setAlwaysInterruptAtStepDownOrUp flag is being used (&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jordi.serra-torrens&quot; class=&quot;user-hover&quot; rel=&quot;jordi.serra-torrens&quot;&gt;jordi.serra-torrens&lt;/a&gt;&#160; is more familiar with the details), to see if there is a better solution, but unfortunately we can&apos;t do this atomic check in the command prologue now. &lt;/p&gt;

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

&lt;p&gt;Note that, in general, the RSTL &lt;em&gt;must&lt;/em&gt; be held to&#160;&lt;em&gt;safely&lt;/em&gt;&#160;read the current replication state; the setAlwaysInterruptAtStepDownOrUp function is&#160;&lt;em&gt;unsynchronized&lt;/em&gt; with this lock and is therefore&#160;&lt;em&gt;unsafe&lt;/em&gt;&#160;without explicitly acquiring the lock if to use if one expects to be a specific replication state when it is called (we hope to make this more clear in the future).&#160;&lt;/p&gt;

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

&lt;p&gt;After talking with Jordi we&apos;ve decided to assign this back to the Sharding EMEA backlog for now so the linked BFs can be re-triaged; then I will close this ticket.&#160;&lt;/p&gt;

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

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1912035">SERVER-61066</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2043397">SERVER-66351</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>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 13 Oct 2021 17:24:49 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 14 weeks, 6 days ago
                        </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>george.wangensteen@mongodb.com</customfieldvalue>
            <customfieldvalue>jordi.serra-torrens@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzqdbz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr4bp3:</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="5425">Sharding EMEA 2021-10-18</customfieldvalue>
    <customfieldvalue id="5426">Sharding EMEA 2021-11-01</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|hzpzl3:</customfieldvalue>

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