<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:37:50 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-34781] Abandoned cursor in a transaction can block other operations</title>
                <link>https://jira.mongodb.org/browse/SERVER-34781</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Suppose a transaction opens a cursor, then abandons it. The locks for that cursor will be held in intent mode, even between batches.&lt;/p&gt;

&lt;p&gt;Now suppose a drop for the database or collection comes in. That drop will &quot;get in line&quot; with a MODE_X lock. In order to be fair to such requests, that pending MODE_X acquisition will block all future intent acquisitions.&#160;&lt;/p&gt;

&lt;p&gt;This will prevent a killCursors from killing the cursor, since it will need to take a collection lock. &lt;del&gt;It looks like it will also prevent the background transaction timeout job from killing it.&lt;/del&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="537583">SERVER-34781</key>
            <summary>Abandoned cursor in a transaction can block other operations</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="13202">Works as Designed</resolution>
                                        <assignee username="backlog-server-repl">Backlog - Replication Team</assignee>
                                    <reporter username="charlie.swanson@mongodb.com">Charlie Swanson</reporter>
                        <labels>
                    </labels>
                <created>Tue, 1 May 2018 21:08:34 +0000</created>
                <updated>Fri, 27 Oct 2023 13:53:49 +0000</updated>
                            <resolved>Wed, 2 May 2018 17:33:11 +0000</resolved>
                                    <version>4.0.0-rc0</version>
                                                    <component>Concurrency</component>
                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>19</watches>
                                                                                                                <comments>
                            <comment id="1880729" author="james.wahlin@10gen.com" created="Wed, 2 May 2018 17:32:59 +0000"  >&lt;p&gt;Created&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-34795&quot; title=&quot;killSessions should kill transactions prior to killing cursors&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-34795&quot;&gt;&lt;del&gt;SERVER-34795&lt;/del&gt;&lt;/a&gt; to handle &lt;tt&gt;killSessions&lt;/tt&gt; operation ordering. I will close this ticket as the reproduction script works as designed once the setParameter is moved to the correct location.&#160;&lt;/p&gt;</comment>
                            <comment id="1880513" author="james.wahlin@10gen.com" created="Wed, 2 May 2018 15:53:22 +0000"  >&lt;blockquote&gt;&lt;p&gt;One approach we could take to prevent&#160;&lt;tt&gt;killSessions&lt;/tt&gt;&#160;from blocking is to kill stashed transaction resources prior to killing cursors. Then the transaction would stop holding locks, so the drop could proceed, so the cursor kill could proceed. That might be something we want to look into.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&#160;I agree that we should change the order of operations when killing sessions. We currently:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Kill operations&lt;/li&gt;
	&lt;li&gt;Kill cursors&lt;/li&gt;
	&lt;li&gt;Kill transactions&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;We should instead:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Kill transactions&lt;/li&gt;
	&lt;li&gt;Kill operations&lt;/li&gt;
	&lt;li&gt;Kill cursors&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;As killing transactions will kill associated cursors, step 3 would be there only to kill cursors that were opened as part of the session but outside of a transaction.&lt;/p&gt;</comment>
                            <comment id="1880428" author="dianna.hohensee" created="Wed, 2 May 2018 15:28:34 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=tess.avitabile&quot; class=&quot;user-hover&quot; rel=&quot;tess.avitabile&quot;&gt;tess.avitabile&lt;/a&gt;, we bump it to 3 hours for testing, so that it doesn&apos;t cause random failures on slow machines using transactions. See &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.7.7/buildscripts/resmokelib/core/programs.py#L51-L57&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this code&lt;/a&gt;. Though not all our testing is covered by that setting, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-34595&quot; title=&quot;transactionLifetimeLimitSeconds parameter should be set to high value for noPassthrough tests&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-34595&quot;&gt;&lt;del&gt;SERVER-34595&lt;/del&gt;&lt;/a&gt; will make the coverage complete.&lt;/p&gt;</comment>
                            <comment id="1880406" author="tess.avitabile" created="Wed, 2 May 2018 15:18:06 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=james.wahlin&quot; class=&quot;user-hover&quot; rel=&quot;james.wahlin&quot;&gt;james.wahlin&lt;/a&gt;, why would the &lt;tt&gt;transactionLifetimeLimitSeconds&lt;/tt&gt; be 10800 at the start of the repro? I thought the default was 60.&lt;/p&gt;</comment>
                            <comment id="1880399" author="dianna.hohensee" created="Wed, 2 May 2018 15:14:14 +0000"  >&lt;p&gt;On a related note, over in&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-34732&quot; title=&quot;collection drop hangs in test of transactions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-34732&quot;&gt;&lt;del&gt;SERVER-34732&lt;/del&gt;&lt;/a&gt; I&apos;m exploring what appears to be a deadlock where PeriodicRunnerASIO, which runs the periodic task to abort expired transactions, is waiting on a IS lock behind a drop cmd waiting for a X lock behind an inactive transaction with an IX lock.&lt;/p&gt;</comment>
                            <comment id="1880325" author="tess.avitabile" created="Wed, 2 May 2018 14:45:48 +0000"  >&lt;p&gt;I&apos;m glad to hear the transaction timeout job will successfully kill the transaction. That is unfortunate that &lt;tt&gt;killCursors&lt;/tt&gt; will block. I would also expect &lt;tt&gt;killSessions&lt;/tt&gt; to block, since the first thing it does is kill all cursors for the session, which requires collection locks.&lt;/p&gt;

&lt;p&gt;I think it is expected behavior that a &lt;tt&gt;drop&lt;/tt&gt; that is blocked behind a transaction will block other operations. The scope document for local snapshot reads explicitly says that catalog operations will block behind transactions.&lt;/p&gt;

&lt;p&gt;One approach we could take to prevent &lt;tt&gt;killSessions&lt;/tt&gt; from blocking is to kill stashed transaction resources prior to killing cursors. Then the transaction would stop holding locks, so the drop could proceed, so the cursor kill could proceed. That might be something we want to look into.&lt;/p&gt;

&lt;p&gt;Even if &lt;tt&gt;killCursors&lt;/tt&gt; did not block, &lt;tt&gt;killCursors&lt;/tt&gt; is not sufficient to kill the transaction, since the transaction survives cursors kills and maintains its locks.&lt;/p&gt;</comment>
                            <comment id="1880177" author="james.wahlin@10gen.com" created="Wed, 2 May 2018 13:33:18 +0000"  >&lt;p&gt;The transaction kill mechanism is not triggering here because the &lt;tt&gt;transactionLifetimeLimitSeconds&lt;/tt&gt; used is 10800 or 3 hours. &lt;tt&gt;Session::_transactionExpireDate&lt;/tt&gt; is compared to Date_t::now() to determine whether a transaction should be aborted. The value for this is set at transaction start time. The&#160;attached script waits to reduce &lt;tt&gt;transactionLifetimeLimitSeconds&lt;/tt&gt;&#160;to 1 second until after the transaction has been started, so it is created with a 3 hour expiration. Moving the setParameter above the transaction start addresses this allowing for transaction kill and MODE_X lock acquisition.&lt;/p&gt;</comment>
                            <comment id="1879722" author="milkie" created="Tue, 1 May 2018 21:38:23 +0000"  >&lt;p&gt;Also, while attempting to kill the cursor with the killCursor command&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/help_16.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; won&#8217;t work, won&#8217;t killing the Session work?  Especially if an admin was trying to diagnose the problem, the currentOp output will show you the session to kill, not the cursor id to kill. &lt;/p&gt;</comment>
                            <comment id="1879709" author="james.wahlin@10gen.com" created="Tue, 1 May 2018 21:34:15 +0000"  >&lt;p&gt;I am surprised that the transaction timeout mechanism is blocked. When a transaction times out we call Session::abortArbitraryTransactionIfExpired() which will first release the transaction Lock and Recovery unit prior to attempting to kill associate cursors. It would be interesting to see where the transaction kill thread is blocked.&lt;/p&gt;</comment>
                            <comment id="1879686" author="david.storch" created="Tue, 1 May 2018 21:13:12 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=spencer&quot; class=&quot;user-hover&quot; rel=&quot;spencer&quot;&gt;spencer&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=tess.avitabile&quot; class=&quot;user-hover&quot; rel=&quot;tess.avitabile&quot;&gt;tess.avitabile&lt;/a&gt;, this feels like a candidate for a 4.0.0-rc0 fixVersion. Abandoning a cursor and then issuing killCursors on it isn&apos;t entirely unusual, and it seems like this could lead to a server that is in a &quot;stuck&quot; state. Please triage, and let me know if you&apos;d like an assist from James or someone else on query.&lt;/p&gt;

&lt;p&gt;Nice work tracking this down &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=charlie.swanson&quot; class=&quot;user-hover&quot; rel=&quot;charlie.swanson&quot;&gt;charlie.swanson&lt;/a&gt;!&lt;/p&gt;</comment>
                            <comment id="1879682" author="spencer" created="Tue, 1 May 2018 21:11:19 +0000"  >&lt;p&gt;Hmm, the fact that it blocks the transaction timeout is the most worrisome part.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=milkie&quot; class=&quot;user-hover&quot; rel=&quot;milkie&quot;&gt;milkie&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=james.wahlin&quot; class=&quot;user-hover&quot; rel=&quot;james.wahlin&quot;&gt;james.wahlin&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="549592">SERVER-35217</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="538035">SERVER-34795</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="185613" name="repro.js" size="1754" author="charlie.swanson@mongodb.com" created="Tue, 1 May 2018 21:07:04 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>11.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25128"><![CDATA[Replication]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 1 May 2018 21:11:19 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 41 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_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>false</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>
                            5 years, 41 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>backlog-server-repl</customfieldvalue>
            <customfieldvalue>charlie.swanson@mongodb.com</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>dianna.hohensee@mongodb.com</customfieldvalue>
            <customfieldvalue>milkie@mongodb.com</customfieldvalue>
            <customfieldvalue>james.wahlin@mongodb.com</customfieldvalue>
            <customfieldvalue>spencer@mongodb.com</customfieldvalue>
            <customfieldvalue>tess.avitabile@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htwznb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hto1jz:</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_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Download the attached &apos;repro.js&apos;, then run:&lt;/p&gt;
&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;python buildscripts/resmoke.py --suites=replica_sets_jscore_passthrough repro.js&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;That will hang forever.&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|htwlw7:</customfieldvalue>

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