<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:12: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-46704] Two phase index build can violate locking ordering and can lead to deadlocks.</title>
                <link>https://jira.mongodb.org/browse/SERVER-46704</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Currently, IndexBuildsCoordinatorMongod::voteCommitIndexBuild() violates the lock ordering, i.e., it tries to acquire RSTL lock in mode IX with &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator_mongod.cpp#L276&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ReplIndexBuildState::mutex&lt;/a&gt; held. As a result, it can deadlock with stepup code path (ReplicationCoordinatorImpl::signalDrainComplete), as it acquires RSTL lock in X mode first, and then tries to send abort or commit signal to index build by holding &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator.cpp#L996&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ReplIndexBuildState::mutex&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note:&lt;br/&gt;
The ticket also address 3 more issues.&lt;br/&gt;
1) Currently, the index build (internal system thread) holds RSTl lock with &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator.cpp#L1857&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;uninterruptible&lt;/a&gt; guard enabled. And, it blocks replication state transition, like, step up, step down. (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-44045&quot; title=&quot;allow secondary index builds to start without unlocking the RSTL&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-44045&quot;&gt;&lt;del&gt;SERVER-44045&lt;/del&gt;&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;2) We are acquiring collection lock in  stronger mode (mode X) in order to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator.cpp#L2074&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;commit&lt;/a&gt; or &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator.cpp#L1824&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;abort&lt;/a&gt;. As, a result, this can lead to deadlocks involving prepared transactions, stepdown and indexBuildsCoordinator.  (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-44722&quot; title=&quot;3 way deadlock can happen between hybrid index build, prepared transactions and stepdown thread on primary that runs index build via coordinator.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-44722&quot;&gt;&lt;del&gt;SERVER-44722&lt;/del&gt;&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;3) Currently IndexBuildsCoordinatorMongod::_waitForNextIndexBuildAction() holds RSTL only for the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator_mongod.cpp#L561-L578&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;while&lt;/a&gt; loop scope. As a result, the primary check that we are doing at this line, can &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator_mongod.cpp#L637-L647&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;no longer be valid&lt;/a&gt;. (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-46989&quot; title=&quot;Index builds should hold RSTL to prevent replication state changes after deciding to commit or abort&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-46989&quot;&gt;&lt;del&gt;SERVER-46989&lt;/del&gt;&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;del&gt;4) Also, index build retries to vote on error without checking &lt;a href=&quot;https://github.com/mongodb/mongo/blob/340c085a7fd3e589442bce69db86d51cae1e82a6/src/mongo/db/index_builds_coordinator_mongod.cpp#L494-L537&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;any interrupts&lt;/a&gt;, like, shutdown interrupts. This makes shutdown to hang forever, as it waits for the index builds to complete.&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;UPDATE&lt;/b&gt;: This ticket won&apos;t address the 3 additional issues. And it will be addressed separately.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1252397">SERVER-46704</key>
            <summary>Two phase index build can violate locking ordering and can lead to deadlocks.</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="suganthi.mani@mongodb.com">Suganthi Mani</assignee>
                                    <reporter username="suganthi.mani@mongodb.com">Suganthi Mani</reporter>
                        <labels>
                    </labels>
                <created>Mon, 9 Mar 2020 13:11:21 +0000</created>
                <updated>Sun, 29 Oct 2023 22:11:07 +0000</updated>
                            <resolved>Thu, 19 Mar 2020 15:12:56 +0000</resolved>
                                                    <fixVersion>4.4.0-rc0</fixVersion>
                    <fixVersion>4.7.0</fixVersion>
                                    <component>Storage</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="2987121" author="xgen-internal-githook" created="Thu, 19 Mar 2020 15:03:49 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;suganthi.mani@mongodb.com&apos;, &apos;name&apos;: &apos;Suganthi Mani&apos;, &apos;username&apos;: &apos;smani87&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-46704&quot; title=&quot;Two phase index build can violate locking ordering and can lead to deadlocks.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-46704&quot;&gt;&lt;del&gt;SERVER-46704&lt;/del&gt;&lt;/a&gt; IndexBuildsCoordinatorMongod::voteCommitIndexBuild should not persist votes with ReplIndexBuildState::mutex lock held.&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 1d7f1c5d9e482b7508a1879eda9835cd1ea2c185)&lt;br/&gt;
Branch: v4.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/bc5c557e3297133d18c26870a781b7bfa92de399&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/bc5c557e3297133d18c26870a781b7bfa92de399&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2987044" author="xgen-internal-githook" created="Thu, 19 Mar 2020 14:44:27 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;suganthi.mani@mongodb.com&apos;, &apos;name&apos;: &apos;Suganthi Mani&apos;, &apos;username&apos;: &apos;smani87&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-46704&quot; title=&quot;Two phase index build can violate locking ordering and can lead to deadlocks.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-46704&quot;&gt;&lt;del&gt;SERVER-46704&lt;/del&gt;&lt;/a&gt; IndexBuildsCoordinatorMongod::voteCommitIndexBuild should not persist votes with ReplIndexBuildState::mutex lock held.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/1d7f1c5d9e482b7508a1879eda9835cd1ea2c185&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/1d7f1c5d9e482b7508a1879eda9835cd1ea2c185&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="1282330">SERVER-46989</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="883309">SERVER-42621</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1009935">SERVER-44722</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1234217">SERVER-46664</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="971168">SERVER-44045</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1277034">SERVER-46910</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1277954">SERVER-46917</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_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="18953"><![CDATA[v4.4]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="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>Thu, 19 Mar 2020 14:44:27 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 46 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>49.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>suganthi.mani@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hx4wjr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hwsqrz:</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="3631">Execution Team 2020-03-09</customfieldvalue>
    <customfieldvalue id="3632">Execution Team 2020-03-23</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|hx4it3:</customfieldvalue>

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