<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:36:09 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-77633] Calling withTransaction with a checked out session may end up in a deadlock (on stepdown)</title>
                <link>https://jira.mongodb.org/browse/SERVER-77633</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Any code running `&lt;a href=&quot;https://github.com/10gen/mongo/blob/cc76b1e01aa0345bd7f06977c7365805e84d8c1e/src/mongo/db/s/config/sharding_catalog_manager.cpp#L1149-L1237&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;withTransaction&lt;/a&gt;` may end up with a deadlock if the given OperationContext holds a SessionId and there is a stepdown during the transaction process. Right now we don&apos;t have any thread that holds a session when `withTransaction` is called, however, it should be fixed to avoid hitting this error in the future.&lt;/p&gt;

&lt;p&gt;The sequence of events leading to a deadlock is the following:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;ins&gt;(&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_green.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;): withTransaction thread&lt;/ins&gt;&lt;/li&gt;
	&lt;li&gt;&lt;ins&gt;(&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_yellow.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;): step-down thread&lt;/ins&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;1. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_green.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) checks out a SessionId&lt;br/&gt;
2. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_green.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) run `withTransaction`&lt;br/&gt;
3. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_yellow.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) step-down thread starts and an &lt;a href=&quot;https://github.com/10gen/mongo/blob/eb548b3822e1a53224a13c7b6c96395dfb6a7afc/src/mongo/db/repl/replication_coordinator_impl.cpp#L2632&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Interruption is sent to all the threads&lt;/a&gt;.&lt;br/&gt;
4. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_green.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) &lt;a href=&quot;https://github.com/10gen/mongo/blob/cc76b1e01aa0345bd7f06977c7365805e84d8c1e/src/mongo/db/s/config/sharding_catalog_manager.cpp#L1163&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;abortTransaction&lt;/a&gt; is executed&lt;br/&gt;
4. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_yellow.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) step-down thread &lt;a href=&quot;https://github.com/10gen/mongo/blob/eb548b3822e1a53224a13c7b6c96395dfb6a7afc/src/mongo/db/repl/replication_coordinator_impl.cpp#L2634-L2635&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;acquires RSTL lock&lt;/a&gt;&lt;br/&gt;
5. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_yellow.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) tries to &lt;a href=&quot;https://github.com/10gen/mongo/blob/ef97bdd7c76afbc5376358bed15e7c5325a329ad/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp#L569&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;checkout all sessions to kill them&lt;/a&gt;&lt;br/&gt;
6. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_yellow.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) gets blocked when trying to checkout the session of thread A&lt;br/&gt;
7. (&lt;ins&gt;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/star_green.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/ins&gt;) gets blocked trying to acquire RSTL lock to abort the transaction.&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;withTransaction&lt;/tt&gt; is a method implemented as a utility for the &lt;tt&gt;ShardingCatalogManager&lt;/tt&gt; when new transactions API didn&apos;t exist.&lt;/p&gt;

&lt;p&gt;The new transaction API &lt;a href=&quot;https://github.com/10gen/mongo/blob/52ecfb60254c6b0627bb0ae4c69b1cb8c46adf59/src/mongo/db/transaction/transaction_api.cpp#L115&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;yields the session attached to the thread&lt;/a&gt; to avoid this scenario. So I suggest getting rid of &lt;tt&gt;withTransaction&lt;/tt&gt; code and using the new transaction API instead. &lt;a href=&quot;https://github.com/10gen/mongo/blob/cc76b1e01aa0345bd7f06977c7365805e84d8c1e/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp#L2180-L2268&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;This&lt;/a&gt; is an example of implementation for the new transaction API&lt;/p&gt;

&lt;p&gt;This issue was discovered when the sessionId was attached to the &lt;a href=&quot;https://github.com/10gen/mongo/blob/cc76b1e01aa0345bd7f06977c7365805e84d8c1e/src/mongo/db/s/config/configsvr_collmod_command.cpp&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ConfigsvrCollMod&lt;/a&gt; request. The sessionId was finally removed to solve quickly the bug.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2354828">SERVER-77633</key>
            <summary>Calling withTransaction with a checked out session may end up in a deadlock (on stepdown)</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="12300">Won&apos;t Do</resolution>
                                        <assignee username="silvia.surroca@mongodb.com">Silvia Surroca</assignee>
                                    <reporter username="silvia.surroca@mongodb.com">Silvia Surroca</reporter>
                        <labels>
                    </labels>
                <created>Wed, 31 May 2023 15:25:23 +0000</created>
                <updated>Thu, 22 Jun 2023 11:25:41 +0000</updated>
                            <resolved>Thu, 22 Jun 2023 11:17:51 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="5517830" author="JIRAUSER1268536" created="Thu, 22 Jun 2023 11:17:51 +0000"  >&lt;p&gt;We&apos;ve decided to don&apos;t address this ticket since any operation is using the &lt;tt&gt;withTransaction&lt;/tt&gt; utility holding a session.&lt;/p&gt;

&lt;p&gt;On one side, the user of withTransaction should yield any resource in case of holding them.&lt;/p&gt;

&lt;p&gt;On the other side, we are migrating the code toward the new transaction API, where this problem is not present any more.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="2354829">SERVER-77634</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2172774">SERVER-71011</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2374524">SERVER-78318</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>1.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_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25133"><![CDATA[Sharding EMEA]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 6 Jun 2023 08:53:30 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        32 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>silvia.surroca@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            32 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>135.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>silvia.surroca@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i2bl9j:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0a1hr:qy</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="7188">Sharding EMEA 2023-06-12</customfieldvalue>
    <customfieldvalue id="7189">Sharding EMEA 2023-06-26</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|i2b7ev:</customfieldvalue>

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