<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:55: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-40466] Unify checks for inMultiDocumentTransaction and friends</title>
                <link>https://jira.mongodb.org/browse/SERVER-40466</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There are multiple ways of checking if an &lt;tt&gt;opCtx&lt;/tt&gt; is in a multi-document transaction. They&apos;re each slightly different in practice and we use them somewhat interchangeably. We should clarify the semantic differences between these three, make sure that any place that uses one is using the correct one, and make it clearer what to do in the future.&lt;/p&gt;

&lt;p&gt;Ways to check:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;inMultiDocumentTransaction&lt;/li&gt;
	&lt;li&gt;seeing if the &lt;tt&gt;opCtx&lt;/tt&gt; has a top level WUOW&lt;/li&gt;
	&lt;li&gt;checking if the read concern on the &lt;tt&gt;opCtx&lt;/tt&gt; is &quot;snapshot&quot;&lt;/li&gt;
&lt;/ol&gt;
</description>
                <environment></environment>
        <key id="729285">SERVER-40466</key>
            <summary>Unify checks for inMultiDocumentTransaction and friends</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="13201">Fixed</resolution>
                                        <assignee username="samy.lanka@mongodb.com">Samyukta Lanka</assignee>
                                    <reporter username="judah.schvimer@mongodb.com">Judah Schvimer</reporter>
                        <labels>
                    </labels>
                <created>Wed, 3 Apr 2019 21:31:14 +0000</created>
                <updated>Sun, 29 Oct 2023 22:22:20 +0000</updated>
                            <resolved>Thu, 8 Aug 2019 15:42:59 +0000</resolved>
                                                    <fixVersion>4.2.1</fixVersion>
                    <fixVersion>4.3.1</fixVersion>
                                    <component>Replication</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="2431600" author="xgen-internal-githook" created="Tue, 24 Sep 2019 18:55:01 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Samyukta Lanka&apos;, &apos;username&apos;: &apos;lankas&apos;, &apos;email&apos;: &apos;samy.lanka@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40466&quot; title=&quot;Unify checks for inMultiDocumentTransaction and friends&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40466&quot;&gt;&lt;del&gt;SERVER-40466&lt;/del&gt;&lt;/a&gt; Unify checks for being in a multi-document transaction&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 77967c90b1a521108c052af235ce7de9742aa95e)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-42755&quot; title=&quot;recover_prepared_txn_with_multikey_write.js should make sure no prepare conflicts are generated on catalog object after restarting node&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-42755&quot;&gt;&lt;del&gt;SERVER-42755&lt;/del&gt;&lt;/a&gt; recover_prepared_txn_with_multikey_write.js should verify absence of prepare conflicts on catalog after restart.&lt;/p&gt;

&lt;p&gt;(cherry picked from commit eaf81228328738b685532c7eb10f833362434061)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-42750&quot; title=&quot;OperationContext::inMultiDocumentTransaction() doesn&amp;#39;t return true when applying operations for prepared transaction during recovery&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-42750&quot;&gt;&lt;del&gt;SERVER-42750&lt;/del&gt;&lt;/a&gt; Set opCtx-&amp;gt;inMultiDocumentTransaction() in transaction recovery.&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 16c17677704a4f979381d593106a0c356088fd30)&lt;br/&gt;
Branch: v4.2&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/1781933c126d2aff697cdb42a8f84b8212db23ad&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/1781933c126d2aff697cdb42a8f84b8212db23ad&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2363024" author="xgen-internal-githook" created="Thu, 8 Aug 2019 15:39:13 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Samy Lanka&apos;, &apos;username&apos;: &apos;lankas&apos;, &apos;email&apos;: &apos;samy.lanka@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40466&quot; title=&quot;Unify checks for inMultiDocumentTransaction and friends&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40466&quot;&gt;&lt;del&gt;SERVER-40466&lt;/del&gt;&lt;/a&gt; Unify checks for being in a multi-document transaction&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/77967c90b1a521108c052af235ce7de9742aa95e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/77967c90b1a521108c052af235ce7de9742aa95e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2321021" author="samy.lanka" created="Thu, 11 Jul 2019 14:15:38 +0000"  >&lt;p&gt;code review: &lt;a href=&quot;https://mongodbcr.appspot.com/494120003/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://mongodbcr.appspot.com/494120003/&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2264026" author="tess.avitabile" created="Wed, 29 May 2019 17:26:34 +0000"  >&lt;p&gt;Great! I&apos;ll put up a patch today. If it can get in before I go on leave, great. If not, we can triage it with the Tech Debt work for someone to get it over the line.&lt;/p&gt;</comment>
                            <comment id="2263942" author="judah.schvimer" created="Wed, 29 May 2019 16:42:21 +0000"  >&lt;p&gt;That all sounds good to me! Should we use this ticket for changing all uses according to the semantics you&apos;ve proposed and rank it in with the &quot;Tech Debt&quot; project?&lt;/p&gt;</comment>
                            <comment id="2263846" author="tess.avitabile" created="Wed, 29 May 2019 15:53:34 +0000"  >&lt;p&gt;I don&apos;t believe there are any bugs here, but we could do some cleanup. The semantics of these three checks are as follows:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;tt&gt;inMultiDocumentTransaction()&lt;/tt&gt;: This is true for transactions in states in-progress or prepared, regardless of whether the transaction resources are stashed in a &lt;tt&gt;SideTransactionBlock&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;Seeing if the &lt;tt&gt;opCtx&lt;/tt&gt;&#160;has a top-level WUOW: This is true for transactions in states in-progress or prepared, with two exceptions: (1) We are in a &lt;tt&gt;SideTransactionBlock&lt;/tt&gt;, (2) We are not between the calls to &lt;tt&gt;unstashTransactionResources()&lt;/tt&gt;&#160;and &lt;tt&gt;stashTransactionResources()&lt;/tt&gt;&#160;in &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a3e57d14769c5eb83499093f65724af09cbc928d/src/mongo/db/service_entry_point_common.cpp#L374&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;invokeWithSessionCheckedOut()&lt;/tt&gt;&lt;/a&gt;. The first is significant. The second is not too significant, since unstashing and stashing happens very close to checking out and checking in the session.&lt;/li&gt;
	&lt;li&gt;Checking if the &lt;tt&gt;readConcern&lt;/tt&gt; level on the &lt;tt&gt;opCtx&lt;/tt&gt; is &quot;snapshot&quot;: This is true throughout a transaction&apos;s lifetime, regardless of whether the transaction resources are stashed in a &lt;tt&gt;SideTransactionBlock&lt;/tt&gt;, but only after the call to &lt;tt&gt;unstashTransactionResources()&lt;/tt&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;My recommendation is to make &lt;tt&gt;inMultiDocumentTransaction()&lt;/tt&gt; the canonical way to check whether we are in a transaction, unless that check must be sensitive to &lt;tt&gt;SideTransactionBlock&lt;/tt&gt;, in which case we should check if the &lt;tt&gt;opCtx&lt;/tt&gt; has a top-level WUOW. We should never check the &lt;tt&gt;readConcern&lt;/tt&gt; level to determine whether we are in a transaction (and making that change will allow us to more easily implement&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41359&quot; title=&quot;Stop upconverting readConcern to snapshot internally for transactions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41359&quot;&gt;&lt;del&gt;SERVER-41359&lt;/del&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;It would additionally be valuable to remove &lt;tt&gt;inActiveOrKilledMultiDocumentTransaction()&lt;/tt&gt;, but that work can be done in&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-39614&quot; title=&quot;Remove inActiveOrKilledMultiDocumentTransaction() from TransactionParticipant&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-39614&quot;&gt;&lt;del&gt;SERVER-39614&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="780880">SERVER-41359</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="698917">SERVER-39627</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="890006">SERVER-42750</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>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.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, 6 May 2019 20:42:11 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 20 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-1449</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, 20 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>12.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>judah.schvimer@mongodb.com</customfieldvalue>
            <customfieldvalue>samy.lanka@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|husxun:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htqjq7:</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="3001">Repl 2019-07-01</customfieldvalue>
    <customfieldvalue id="3026">Repl 2019-07-15</customfieldvalue>
    <customfieldvalue id="3028">Repl 2019-07-29</customfieldvalue>
    <customfieldvalue id="3106">Repl 2019-08-12</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|husk3z:</customfieldvalue>

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