<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:43:03 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-36421] Commit transaction command does not properly abort the transaction if onTransactionCommit throws an exception</title>
                <link>https://jira.mongodb.org/browse/SERVER-36421</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;When we run &lt;tt&gt;commitTransaction&lt;/tt&gt;, we will call the&#160;&lt;tt&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/84cb23553ecca69fb2ec84dbd4aa13bb18f26b47/src/mongo/db/session.cpp#L1057&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Session::commitUnpreparedTransaction&lt;/a&gt;&lt;/tt&gt; method (or the analogous method for prepared transactions). Inside this method, we will first &lt;a href=&quot;https://github.com/mongodb/mongo/blob/84cb23553ecca69fb2ec84dbd4aa13bb18f26b47/src/mongo/db/session.cpp#L1067&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;transition&lt;/a&gt; to state &quot;kCommittingWithoutPrepare&quot;, and then trigger the &lt;tt&gt;onTransactionCommit&lt;/tt&gt; OpObserver. Inside that OpObserver call is where we will do a write to update the &lt;tt&gt;config.transactions&lt;/tt&gt; table. If the the &lt;tt&gt;onTransactionCommit&lt;/tt&gt; method throws an exception, then the &lt;tt&gt;commitTransaction&lt;/tt&gt; command will fail, and we will have left the transaction state in &quot;kCommittingWithoutPrepare&quot;. When a command running inside a transaction throws an exception, we will trigger &lt;a href=&quot;https://github.com/mongodb/mongo/blob/7a97557ce5bf74dc2b663762b7a5ffb9c958d580/src/mongo/db/service_entry_point_common.cpp#L474&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this block&lt;/a&gt;, to abort the transaction if necessary. In the case described, we would call &lt;tt&gt;Session::abortActiveTransaction&lt;/tt&gt; while the transaction is still in state &quot;kCommittingWithoutPrepare&quot;. Since we are not in one of the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/84cb23553ecca69fb2ec84dbd4aa13bb18f26b47/src/mongo/db/session.cpp#L910&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;expected states&lt;/a&gt; passed to &lt;tt&gt;_abortActiveTransaction&lt;/tt&gt;, we &lt;a href=&quot;https://github.com/mongodb/mongo/blob/84cb23553ecca69fb2ec84dbd4aa13bb18f26b47/src/mongo/db/session.cpp#L930-L936&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;will not execute&lt;/a&gt; the &lt;tt&gt;_abortTransactionOnSession&lt;/tt&gt; method, which is what actually updates the various metadata about the transaction, to indicate that it is aborted. We will, however, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/84cb23553ecca69fb2ec84dbd4aa13bb18f26b47/src/mongo/db/session.cpp#L942-L944&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;clean up the transaction resources&lt;/a&gt; that live on the OperationContext. So, even though we called &lt;tt&gt;abortActiveTransaction&lt;/tt&gt;, we never actually transitioned to the &quot;kAborted&quot; state.&lt;/p&gt;

&lt;p&gt;The issue can then persist, because the transaction has been left in the &quot;kCommittingWithoutPrepare&quot; state. For example, when we try to run another commit command, we will get an &lt;a href=&quot;https://github.com/mongodb/mongo/blob/ef5eda3683d647f0626babd0a01e9b62c2705c08/src/mongo/db/commands/txn_cmds.cpp#L146-L148&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;error&lt;/a&gt; because the transaction is no longer marked as in-progress. The &lt;a href=&quot;https://github.com/mongodb/mongo/blob/ef5eda3683d647f0626babd0a01e9b62c2705c08/src/mongo/db/commands/txn_cmds.cpp#L194-L196&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;same error&lt;/a&gt; will also be thrown if we try to run abort. One way to get the transaction out of this &quot;limbo&quot; state is to start a new transaction with a higher transaction number on the same session. This will work as a way to clear out the old transaction state, but it still won&apos;t trigger an actual call to &lt;tt&gt;_abortTransactionOnSession&lt;/tt&gt; for the previous transaction. When we start a new transaction when one is already running, we will only &lt;a href=&quot;https://github.com/mongodb/mongo/blob/ef5eda3683d647f0626babd0a01e9b62c2705c08/src/mongo/db/session.cpp#L605&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;abort the old transaction&lt;/a&gt; if there &lt;a href=&quot;https://github.com/mongodb/mongo/blob/ef5eda3683d647f0626babd0a01e9b62c2705c08/src/mongo/db/session.cpp#L1008-L1010&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;is one in progress&lt;/a&gt;. This means we would start the new transaction without ever explicitly calling the abort method internally. &lt;/p&gt;

&lt;p&gt;To fix this, we should probably make sure that we explicitly abort the transaction right away if an exception is thrown inside the OpObserver.&lt;/p&gt;</description>
                <environment></environment>
        <key id="581521">SERVER-36421</key>
            <summary>Commit transaction command does not properly abort the transaction if onTransactionCommit throws an exception</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="siyuan.zhou@mongodb.com">Siyuan Zhou</assignee>
                                    <reporter username="william.schultz@mongodb.com">William Schultz</reporter>
                        <labels>
                            <label>prepare_basic</label>
                    </labels>
                <created>Thu, 2 Aug 2018 20:06:14 +0000</created>
                <updated>Sun, 29 Oct 2023 22:29:20 +0000</updated>
                            <resolved>Mon, 13 Aug 2018 19:14:12 +0000</resolved>
                                    <version>4.1.1</version>
                                    <fixVersion>4.1.2</fixVersion>
                                    <component>Replication</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="1974510" author="xgen-internal-githook" created="Mon, 13 Aug 2018 19:13:57 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Siyuan Zhou&apos;, &apos;email&apos;: &apos;siyuan.zhou@mongodb.com&apos;, &apos;username&apos;: &apos;visualzhou&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-36421&quot; title=&quot;Commit transaction command does not properly abort the transaction if onTransactionCommit throws an exception&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-36421&quot;&gt;&lt;del&gt;SERVER-36421&lt;/del&gt;&lt;/a&gt; Keep being InProgress when writing oplog entry for unprepared commit.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/3fc7971ea53270cccf5bf164862186e19de9a185&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/3fc7971ea53270cccf5bf164862186e19de9a185&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1964401" author="siyuan.zhou@10gen.com" created="Thu, 2 Aug 2018 20:22:16 +0000"  >&lt;p&gt;Looked into this with Will. We believe this isn&apos;t a problem in 4.0 because the transaction state is still &lt;a href=&quot;https://github.com/mongodb/mongo/blob/54f1582fc6eb01de4d4c42f26fc133e623f065fb/src/mongo/db/session.cpp#L946&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;`kInProgress` when we call OpObserver&lt;/a&gt;. We moved the transition to kCommitting to earlier in 4.2. I think it&apos;s correct to think the transition is in progress when committing unprepared transaction calls OpObserver, since it hasn&apos;t touch anything on the disk and all data change is in WUOW, which hasn&apos;t committed yet.&lt;/p&gt;</comment>
                            <comment id="1964383" author="william.schultz" created="Thu, 2 Aug 2018 20:10:32 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=siyuan.zhou&quot; class=&quot;user-hover&quot; rel=&quot;siyuan.zhou&quot;&gt;siyuan.zhou&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=judah.schvimer&quot; class=&quot;user-hover&quot; rel=&quot;judah.schvimer&quot;&gt;judah.schvimer&lt;/a&gt; This was discovered after looking into an apparent issue with transactions metrics reported by Bruce Lucas. After discussing with Siyuan, however, I think the core bug is not related to the transactions metrics logic, but with how we track and update transaction state in the session.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="576531">SERVER-36295</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>3.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_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 2 Aug 2018 20:22:16 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 26 weeks, 2 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-1032</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>
                            5 years, 26 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>28.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>siyuan.zhou@mongodb.com</customfieldvalue>
            <customfieldvalue>william.schultz@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu4c6n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|httc1r:</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="2447">Repl 2018-08-13</customfieldvalue>
    <customfieldvalue id="2448">Repl 2018-08-27</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|hu3yfz:</customfieldvalue>

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