<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:59:14 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-41980] Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.</title>
                <link>https://jira.mongodb.org/browse/SERVER-41980</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Let&apos;s assume the number of write tickets available = 1. Consider the below sequence.&#160;&lt;/p&gt;

&lt;p&gt;1) Transaction gets prepared and waits to commit.&#160; Once the prepare succeeds on primary, as a part of stashing the lock resources, we &lt;a href=&quot;https://github.com/mongodb/mongo/blob/e5d7c73e7eb9f3bfe70925dd3154ca348b1ee285/src/mongo/db/transaction_participant.cpp#L683&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;release the ticket&lt;/a&gt; but hold the global lock in IX mode.&lt;br/&gt;
 2)&#160; Now, commands (like create, find, insert) not running in transaction comes in and &lt;a href=&quot;https://github.com/mongodb/mongo/blob/e5d7c73e7eb9f3bfe70925dd3154ca348b1ee285/src/mongo/db/concurrency/lock_state.cpp#L374&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;acquires the ticket&lt;/a&gt; and global lock but gets blocked behind the prepared txn on a prepare conflict or DB/collection level lock conflict.&lt;br/&gt;
 3) Next, commitTransaction cmd comes in and as a part of unstashing the lock resources, the commit cmd will try to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/e5d7c73e7eb9f3bfe70925dd3154ca348b1ee285/src/mongo/db/transaction_participant.cpp#L738&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reacquire the ticket&lt;/a&gt;. But, it fails and gets blocked by the&#160;non-transactional ops in step no:2&lt;/p&gt;

&lt;p&gt;For a cross-shard transactions, the transaction coordinator keeps retrying the&#160;commitTransaction cmd until it succeeds. But due to above deadlock, &lt;b&gt;there won&apos;t be any progress on the primary&lt;/b&gt;. The above deadlock happens on primary because the transaction violates the ordering while unstashing the lock resources where ticket is acquired with the global lock held.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: The above is a problem only for a prepared txns ( commitTransaction cmd + cross-shard transaction combo) and not for unprepared txns because the transactions gets aborted either by the transaction reaper or by the higher transaction number (see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41976&quot; title=&quot;Server should not attach TransientTransactionError label  to prepared transaction commands (commit) when the command fails with  LockTimeout.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41976&quot;&gt;&lt;del&gt;SERVER-41976&lt;/del&gt;&lt;/a&gt;) which would allow step no:2 to proceed.&lt;/p&gt;</description>
                <environment></environment>
        <key id="823820">SERVER-41980</key>
            <summary>Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.</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>Thu, 27 Jun 2019 19:29:04 +0000</created>
                <updated>Sun, 29 Oct 2023 22:19:28 +0000</updated>
                            <resolved>Thu, 25 Jul 2019 04:11:51 +0000</resolved>
                                                    <fixVersion>4.2.0-rc5</fixVersion>
                    <fixVersion>4.3.1</fixVersion>
                                    <component>Replication</component>
                                        <votes>0</votes>
                                    <watches>8</watches>
                                                                                                                <comments>
                            <comment id="2342715" author="xgen-internal-githook" created="Thu, 25 Jul 2019 04:10:09 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Suganthi Mani&apos;, &apos;email&apos;: &apos;suganthi.mani@mongodb.com&apos;, &apos;username&apos;: &apos;smani87&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41980&quot; title=&quot;Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41980&quot;&gt;&lt;del&gt;SERVER-41980&lt;/del&gt;&lt;/a&gt; Prepared transactions should not acquire ticket on primary.&lt;/p&gt;

&lt;p&gt;(cherry picked from commit be06cfaae8872737fe349a8a400f322123307061)&lt;br/&gt;
Branch: v4.2&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/24c1ddcbee28eb2e3901a3cbdd03debde8be48c1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/24c1ddcbee28eb2e3901a3cbdd03debde8be48c1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2342709" author="xgen-internal-githook" created="Thu, 25 Jul 2019 04:07:13 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Suganthi Mani&apos;, &apos;email&apos;: &apos;suganthi.mani@mongodb.com&apos;, &apos;username&apos;: &apos;smani87&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41980&quot; title=&quot;Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41980&quot;&gt;&lt;del&gt;SERVER-41980&lt;/del&gt;&lt;/a&gt; Prepared transactions should not acquire ticket on primary.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/be06cfaae8872737fe349a8a400f322123307061&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/be06cfaae8872737fe349a8a400f322123307061&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2339208" author="xgen-internal-githook" created="Tue, 23 Jul 2019 16:23:45 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ian Boros&apos;, &apos;email&apos;: &apos;puppyofkosh@gmail.com&apos;, &apos;username&apos;: &apos;puppyofkosh&apos;}
&lt;p&gt;Message: Revert &quot;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41980&quot; title=&quot;Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41980&quot;&gt;&lt;del&gt;SERVER-41980&lt;/del&gt;&lt;/a&gt; Prepared transactions should not acquire ticket on primary.&quot;&lt;/p&gt;

&lt;p&gt;This reverts commit aa4089f9d3abccdf4724c6c49a8bde504359b800.&lt;br/&gt;
Branch: v4.2&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/3bfb22c6ee0d45b7144b5cbe864fa88afe471215&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/3bfb22c6ee0d45b7144b5cbe864fa88afe471215&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2339192" author="xgen-internal-githook" created="Tue, 23 Jul 2019 16:17:21 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ian Boros&apos;, &apos;email&apos;: &apos;puppyofkosh@gmail.com&apos;, &apos;username&apos;: &apos;puppyofkosh&apos;}
&lt;p&gt;Message: Revert &quot;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41980&quot; title=&quot;Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41980&quot;&gt;&lt;del&gt;SERVER-41980&lt;/del&gt;&lt;/a&gt; Prepared transactions should not acquire ticket on primary.&quot;&lt;/p&gt;

&lt;p&gt;This reverts commit a5d4ab967af9cbba17e6aa5afadca35927bd74c1.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/e529848702394e0b030d8d0eb0a61d03950a27a6&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/e529848702394e0b030d8d0eb0a61d03950a27a6&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2335740" author="xgen-internal-githook" created="Mon, 22 Jul 2019 02:59:35 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Suganthi Mani&apos;, &apos;email&apos;: &apos;suganthi.mani@mongodb.com&apos;, &apos;username&apos;: &apos;smani87&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41980&quot; title=&quot;Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41980&quot;&gt;&lt;del&gt;SERVER-41980&lt;/del&gt;&lt;/a&gt; Prepared transactions should not acquire ticket on primary.&lt;/p&gt;

&lt;p&gt;(cherry picked from commit a5d4ab967af9cbba17e6aa5afadca35927bd74c1)&lt;br/&gt;
Branch: v4.2&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/aa4089f9d3abccdf4724c6c49a8bde504359b800&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/aa4089f9d3abccdf4724c6c49a8bde504359b800&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2335739" author="xgen-internal-githook" created="Mon, 22 Jul 2019 02:56:24 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Suganthi Mani&apos;, &apos;username&apos;: &apos;smani87&apos;, &apos;email&apos;: &apos;suganthi.mani@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41980&quot; title=&quot;Non-transactional commands can deadlock with prepared transactions when the tickets are exhausted by the non-transactional write commands.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41980&quot;&gt;&lt;del&gt;SERVER-41980&lt;/del&gt;&lt;/a&gt; Prepared transactions should not acquire ticket on primary.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/a5d4ab967af9cbba17e6aa5afadca35927bd74c1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/a5d4ab967af9cbba17e6aa5afadca35927bd74c1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2318042" author="suganthi.mani" created="Tue, 9 Jul 2019 22:47:24 +0000"  >&lt;p&gt;Quick note, this problem applies even for abortTransaction cmd + cross-shard transaction combo as the txn coordinator keeps retrying the&#160;abortTransaction cmd.&lt;/p&gt;</comment>
                            <comment id="2316113" author="suganthi.mani" created="Mon, 8 Jul 2019 23:02:41 +0000"  >&lt;p&gt;Spoke with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=geert.bosch&quot; class=&quot;user-hover&quot; rel=&quot;geert.bosch&quot;&gt;geert.bosch&lt;/a&gt;&#160;and we agreed on a solution where a commitTransaction cmd &lt;a href=&quot;https://github.com/mongodb/mongo/blob/e5d7c73e7eb9f3bfe70925dd3154ca348b1ee285/src/mongo/db/transaction_participant.cpp#L738&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;should not reacquire the ticket&lt;/a&gt; while unstashing the lock resources (like we do it in &lt;a href=&quot;https://github.com/mongodb/mongo/blob/e5d7c73e7eb9f3bfe70925dd3154ca348b1ee285/src/mongo/db/ftdc/collector.cpp#L71&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ftdc&lt;/a&gt;).&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="790517">SERVER-41556</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="874651">SERVER-42398</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8.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="16775"><![CDATA[v4.2]]></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>Mon, 22 Jul 2019 02:56:24 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 29 weeks 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>
                            4 years, 29 weeks 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>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|hv8qjz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr84vr:</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="3026">Repl 2019-07-15</customfieldvalue>
    <customfieldvalue id="3028">Repl 2019-07-29</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|hv8ctb:</customfieldvalue>

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