<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:05:33 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-66477] Deadlock during stepup when there is a prepared transaction and migration recipient recovery needs to be run</title>
                <link>https://jira.mongodb.org/browse/SERVER-66477</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There exists a possible deadlock on stepup involving a particular interleaving of a transaction starting and becoming prepared (ii) and a stepdown during a chunk migration.&lt;/p&gt;

&lt;p&gt;Consider the following interleaving:&lt;br/&gt;
1.A chunk migration recipient that has &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3efbb9a26eba7f40392b3921ed0162c80b6b6d1/src/mongo/db/s/migration_destination_manager.cpp#L1835-L1836&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;exited its critical section&lt;/a&gt; but not yet &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3efbb9a26eba7f40392b3921ed0162c80b6b6d1/src/mongo/db/s/migration_destination_manager.cpp#L1854-L1855&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;removed its recovery document&lt;/a&gt;. &lt;br/&gt;
2. As soon as the critical section was released, a new prepared transaction could have started and reached the prepare state.&lt;br/&gt;
3. The recipient primary down steps down. because the migration recipient recovery document still exists, the upcoming primary will need to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fbdcf79b38b141aa89d7b38ddcf40d4065c4c2ae/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp#L975&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;recover it&lt;/a&gt;. Then, still under drain mode, this involves &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3efbb9a26eba7f40392b3921ed0162c80b6b6d1/src/mongo/db/s/migration_destination_manager.cpp#L503-L504&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reacquiring the critical section&lt;/a&gt;, which requires &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fbdcf79b38b141aa89d7b38ddcf40d4065c4c2ae/src/mongo/db/s/recoverable_critical_section_service.cpp#L101&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;taking the collection lock in MODE_S&lt;/a&gt;.&lt;br/&gt;
However, because there was a prepared transaction (whose locks are &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fbdcf79b38b141aa89d7b38ddcf40d4065c4c2ae/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp#L480&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reacquired earlier in the stepup sequence&lt;/a&gt;), the migration recovery won&apos;t be able to acquire the lock and will deadlock on stepup.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2047199">SERVER-66477</key>
            <summary>Deadlock during stepup when there is a prepared transaction and migration recipient recovery needs to be run</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="9">Done</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>Mon, 16 May 2022 13:37:27 +0000</created>
                <updated>Fri, 15 Sep 2023 18:38:37 +0000</updated>
                            <resolved>Tue, 17 May 2022 14:53:26 +0000</resolved>
                                    <version>5.3.0</version>
                    <version>6.0.0-rc0</version>
                                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="4553190" author="JIRAUSER1257318" created="Tue, 17 May 2022 14:53:12 +0000"  >&lt;p&gt;This has been addressed by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-65947&quot; title=&quot;MigrationDestinationManager must recover if an error occurs during release of the critical section&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-65947&quot;&gt;&lt;del&gt;SERVER-65947&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="4549640" author="JIRAUSER1257318" created="Mon, 16 May 2022 13:51:43 +0000"  >&lt;p&gt;This could be addressed by moving the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3efbb9a26eba7f40392b3921ed0162c80b6b6d1/src/mongo/db/s/migration_destination_manager.cpp#L503-L511&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reacquisition of the migration recipient critical section&lt;/a&gt; to happen outside of drain mode, on the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3efbb9a26eba7f40392b3921ed0162c80b6b6d1/src/mongo/db/s/migration_destination_manager.cpp#L517-L518&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;migrateThread&lt;/a&gt; instead. Additionally, we should then ensure that _recvChunkCommit waits for the critical section to be majority committed (we only wait for &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3efbb9a26eba7f40392b3921ed0162c80b6b6d1/src/mongo/db/s/migration_destination_manager.cpp#L1598-L1600&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;local wc now&lt;/a&gt;).&lt;br/&gt;
&lt;em&gt;Justification&lt;/em&gt;: On the happy path, when _recvChunkCommit  returns it will be guaranteed that the recipient is holding the critical section. Also, since we use the RecoverableCriticalSection, if the recipient steps down after this point, the critical section will already persist. It is not necessary to retake it under drain mode.&lt;/p&gt;

&lt;p&gt;Possible fix patch:  &lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/attachment/379069/379069_0001-BF-25230-fix.patch&quot; title=&quot;0001-BF-25230-fix.patch attached to SERVER-66477&quot;&gt;0001-BF-25230-fix.patch&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt; &lt;/p&gt;

&lt;p&gt;The current PR for &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-65947&quot; title=&quot;MigrationDestinationManager must recover if an error occurs during release of the critical section&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-65947&quot;&gt;&lt;del&gt;SERVER-65947&lt;/del&gt;&lt;/a&gt; already implements this solution. Leaving this ticket open until decision is made about possibly backporting &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-65947&quot; title=&quot;MigrationDestinationManager must recover if an error occurs during release of the critical section&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-65947&quot;&gt;&lt;del&gt;SERVER-65947&lt;/del&gt;&lt;/a&gt; to 6.0.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2032962">SERVER-65947</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2443813">SERVER-81116</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="379069" name="0001-BF-25230-fix.patch" size="2718" author="jordi.serra-torrens@mongodb.com" created="Mon, 16 May 2022 13:50:22 +0000"/>
                            <attachment id="379068" name="0001-Repro-BF-25230.patch" size="3926" author="jordi.serra-torrens@mongodb.com" created="Mon, 16 May 2022 13:36:16 +0000"/>
                    </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>1.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 38 weeks, 1 day 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>m.maher@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 38 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>153.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>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|i0uyfr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0dv40:</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="6075">Sharding EMEA 2022-05-30</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;./buildscripts/resmoke.py run --storageEngine=wiredTiger --storageEngineCacheSizeGB=.50 --suite=sharding jstests/sharding/repro-bf-25230.js --log=file&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</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|i0ukl3:</customfieldvalue>

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