<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:13:28 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-69443] [4.4] Allow speculative majority reads in multi-doc txns when --enableMajorityReadConcern=false</title>
                <link>https://jira.mongodb.org/browse/SERVER-69443</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Affects 4.4 (observed on 4.4.17-rc0), doesn&apos;t seem to affect 4.2 (doesn&apos;t reproduce on 4.2.22). Doesn&apos;t affect 5.0+ as support for majority read concern is &lt;a href=&quot;https://www.mongodb.com/docs/manual/reference/program/mongod/#std-option-mongod.--enableMajorityReadConcern&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;always on&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Behaviour:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Multi-doc txn with txnNumber:0 and readConcern: 
{ level: &apos;majority&apos; }
&lt;p&gt;  returns &quot;Given transaction number 0 does not match any in-progress transactions&quot;.&lt;/p&gt;
	&lt;ul&gt;
		&lt;li&gt;I believe it should return &quot;Majority read concern is not enabled&quot; instead.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Multi-doc txn with txnNumber:0 and readConcern: 
{ level: &apos;majority&apos; }
&lt;p&gt; and allowSpeculativeMajorityRead: true returns &quot;Given transaction number 0 does not match any in-progress transactions&quot;.&lt;/p&gt;
	&lt;ul&gt;
		&lt;li&gt;I believe it should return &quot;Majority read concern is not enabled&quot; instead.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Multi-doc txn with txnNumber: 1 and readConcern: 
{ level: &apos;majority&apos; }
&lt;p&gt;: aborts with &quot;Majority read concern is not enabled&quot;&lt;/p&gt;
	&lt;ul&gt;
		&lt;li&gt;This is expected.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Multi-doc txn with txn txnNumber:1 and readConcern: 
{ level: &apos;majority&apos; }
&lt;p&gt; and allowSpeculativeMajorityRead: true crashes the server.&lt;/p&gt;
	&lt;ul&gt;
		&lt;li&gt;I believe it should return &quot;Majority read concern is not enabled&quot; instead.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2129314">SERVER-69443</key>
            <summary>[4.4] Allow speculative majority reads in multi-doc txns when --enableMajorityReadConcern=false</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="ali.mir@mongodb.com">Ali Mir</assignee>
                                    <reporter username="josef.ahmad@mongodb.com">Josef Ahmad</reporter>
                        <labels>
                    </labels>
                <created>Mon, 5 Sep 2022 14:01:18 +0000</created>
                <updated>Sun, 29 Oct 2023 21:33:35 +0000</updated>
                            <resolved>Fri, 30 Sep 2022 17:25:56 +0000</resolved>
                                                    <fixVersion>4.4.18</fixVersion>
                                                        <votes>0</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="4869370" author="xgen-internal-githook" created="Fri, 30 Sep 2022 17:20:09 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;ali-mir&apos;, &apos;email&apos;: &apos;ali.mir@mongodb.com&apos;, &apos;username&apos;: &apos;ali-mir&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-69443&quot; title=&quot;[4.4] Allow speculative majority reads in multi-doc txns when --enableMajorityReadConcern=false&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-69443&quot;&gt;&lt;del&gt;SERVER-69443&lt;/del&gt;&lt;/a&gt; Disallow speculative majority find operations in transactions&lt;br/&gt;
Branch: v4.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/5465c8fa07c96e06a57bbae867a065119657814f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/5465c8fa07c96e06a57bbae867a065119657814f&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4835300" author="ali.mir" created="Fri, 16 Sep 2022 22:12:09 +0000"  >&lt;p&gt;Took a quick look at why this issue isn&apos;t reproducible on 4.2. It appears that regardless of the &quot;majority&quot; read concern passed into the find command in the transaction, we override it and replace it with readConcern: snapshot &lt;a href=&quot;https://github.com/10gen/mongo/blob/743bf3063008f02ea3ffab17757d60d63862a1c9/src/mongo/db/repl/read_concern_args.cpp#L276&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;. As we can only be in speculative majority if the readConcern is majority, we skip the invariant entirely. This functionality was removed in 4.4.&lt;/p&gt;

&lt;p&gt;As a result, the fix only has to go into 4.4 (as versions &amp;gt;= 5.0 has emrc=true).&lt;/p&gt;</comment>
                            <comment id="4824112" author="ali.mir" created="Tue, 13 Sep 2022 21:23:06 +0000"  >&lt;p&gt;As a note (to myself) we&apos;ll need to prevent speculative majority finds from running in transactions in the fuzzer.&lt;/p&gt;</comment>
                            <comment id="4823544" author="kyle.suarez" created="Tue, 13 Sep 2022 18:46:39 +0000"  >&lt;p&gt;After consulting with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=christopher.harris%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;christopher.harris@mongodb.com&quot;&gt;christopher.harris@mongodb.com&lt;/a&gt;, it sounds fine to Query to ban these speculative majority finds in transactions. However, please run the usual patch builds and let Query know if anything is red (we don&apos;t &lt;em&gt;expect&lt;/em&gt; anything to break.... but better safe than sorry).&lt;/p&gt;</comment>
                            <comment id="4813204" author="ali.mir" created="Thu, 8 Sep 2022 22:01:31 +0000"  >&lt;p&gt;Question for query execution: are there any concerns with banning speculative majority find commands in transactions? Speculative majority finds and transactions seem to have conflicting behavior with regards to ReadSource, and we could uassert in the find code path. It seems to me that this would be a low disruption change, given that really the only case we are banning is a find command with speculative majority (and the field is internal/undocumented) as the first operation in a transaction. cc &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kyle.suarez%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;kyle.suarez@mongodb.com&quot;&gt;kyle.suarez@mongodb.com&lt;/a&gt; (feel free to tag in anyone that might have more context!). Let me know if there is something I&apos;m missing from my investigation, or if you want to chat more about this!&lt;/p&gt;</comment>
                            <comment id="4812805" author="ali.mir" created="Thu, 8 Sep 2022 19:42:41 +0000"  >&lt;p&gt;I&apos;ve confirmed that transactions do not support the $changeStream aggregation stage (&lt;a href=&quot;https://github.com/10gen/mongo/blob/95f7351385d89754877e239bfbe59acf644ba883/src/mongo/db/pipeline/document_source_change_stream.h#L97-L99&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;function here&lt;/a&gt;) by running a jstest. &lt;/p&gt;

&lt;p&gt;It looks like the find command case is the only command that can trigger the invariant within a transaction on v4.4.&lt;/p&gt;</comment>
                            <comment id="4812783" author="ali.mir" created="Thu, 8 Sep 2022 19:32:40 +0000"  >&lt;p&gt;It appears that with even with emrc=false, find commands with readConcern: majority and allowSpeculativeMajorityReads: true should still succeed.  We use the allowSpeculativeMajorityReads flag to provide &apos;majority&apos; read guarantees even when the storage engine doesn&apos;t support reading from historical snapshot, as described by this &lt;a href=&quot;https://github.com/10gen/mongo/blob/e141d191fce0176fbaaafb91d8eb5e127c8b25ed/jstests/replsets/speculative_majority_find.js&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;test on the v4.4 branch&lt;/a&gt;. As a result, just returning a &quot;Majority read concern is not enabled&quot; error for allowSpeculativeMajorityReads flagged commands in a transaction is a little misleading.&lt;/p&gt;

&lt;p&gt;The failure arises because of the invariant check &lt;a href=&quot;https://github.com/10gen/mongo/blob/95f7351385d89754877e239bfbe59acf644ba883/src/mongo/db/read_concern_mongod.cpp#L499-L500&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;. We expect the ReadSource of any speculative majority read command to be &lt;a href=&quot;https://github.com/10gen/mongo/blob/95f7351385d89754877e239bfbe59acf644ba883/src/mongo/db/read_concern_mongod.cpp#L498&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;kNoOverlap&lt;/a&gt;. However, &lt;a href=&quot;https://github.com/10gen/mongo/blob/95f7351385d89754877e239bfbe59acf644ba883/src/mongo/db/transaction_participant.cpp#L642-L647&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;we will always set the ReadSource to kNoTimestamp&lt;/a&gt; for transactions with readConcern local or majority. Therefore, any transaction with readConcern:majority, the speculative majority flag, and emrc=false will trigger this invariant.&lt;/p&gt;

&lt;p&gt;To me, it sounds like conflicting behavior, so my proposal is that we ban speculative majority commands from transactions entirely.  Given that this is an internal only field, and is used only in two places (according to &lt;a href=&quot;https://github.com/10gen/mongo/blob/95f7351385d89754877e239bfbe59acf644ba883/jstests/replsets/speculative_majority_supported_commands.js#L4-L5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this comment&lt;/a&gt;, in changestreams and the find command), it shouldn&apos;t be too disruptive of a change.&lt;/p&gt;

&lt;p&gt;Some other notes:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;This invariant only triggers when emrc=false. For emrc=true cases, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/v4.4/src/mongo/db/repl/read_concern_args.cpp#L277-L280&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;isSpeculativeMajority will return false&lt;/a&gt;, so we will never hit the invariant check. This is because isSpeculativeMajority checks that the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/v4.4/src/mongo/db/repl/read_concern_args.cpp#L279&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;_majorityReadMechanism&lt;/a&gt; is kSpeculative, and &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1744ab66eafba2dcc6dd96d7fa0d0d77eeae35d8/src/mongo/db/service_entry_point_common.cpp#L392-L400&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;we only set the _majorityReadMechanism to kSpeculative&lt;/a&gt; when readConcern is majority, is the allowSpeculativeMajorityReads flag is enabled, and if emrc=false.&lt;/li&gt;
	&lt;li&gt;The allowSpeculativeMajorityRead flag is undocumented, so the only way a user can trigger this invariant is if they start a transaction and immediately issue a find with the undocumented field.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                                                <inwardlinks description="is documented by">
                                        <issuelink>
            <issuekey id="2149162">DOCS-15661</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.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, 8 Sep 2022 19:32:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 18 weeks, 5 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_17052" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Downstream Changes Summary</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>This ticket bans the use of the &amp;#39;allowSpeculativeMajorityReads&amp;#39; flag for the &amp;#39;find&amp;#39; command in transactions. This is a very niche use case, and only exists on 4.4, so I&amp;#39;ll let the Docs team decide if this is something we need to document for users.</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16942"><![CDATA[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>
                            1 year, 18 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>102.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>ali.mir@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>josef.ahmad@mongodb.com</customfieldvalue>
            <customfieldvalue>kyle.suarez@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i18z2n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0rpr4:</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_22250" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Special Downgrade Instructions Required</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23343"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="6341">Repl 2022-09-19</customfieldvalue>
    <customfieldvalue id="6514">Repl 2022-10-03</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_17051" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Teams Impacted</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16944"><![CDATA[Docs]]></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|i18l7z:</customfieldvalue>

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