<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:51:39 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-39310] Check canServeReadsFor in getMores</title>
                <link>https://jira.mongodb.org/browse/SERVER-39310</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;The &quot;getMore&quot; command path appears to never call &lt;tt&gt;canServeReadsFor&lt;/tt&gt;, meaning that we could end up serving reads during a rollback. Data in this time could be inconsistent. For rollback via refetch, we refetch documents from the future and then play updates on them from the past which can lead to documents that never existed being returned. Rollback to a Timestamp is likely safe since it never is in an inconsistent state, but it&apos;s worthwhile to be consistent with the &quot;find&quot; command here. &lt;/p&gt;

&lt;p&gt;Discovered by &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=david.storch&quot; class=&quot;user-hover&quot; rel=&quot;david.storch&quot;&gt;david.storch&lt;/a&gt;.&lt;/p&gt;</description>
                <environment></environment>
        <key id="681083">SERVER-39310</key>
            <summary>Check canServeReadsFor in getMores</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="lingzhi.deng@mongodb.com">Lingzhi Deng</assignee>
                                    <reporter username="judah.schvimer@mongodb.com">Judah Schvimer</reporter>
                        <labels>
                    </labels>
                <created>Thu, 31 Jan 2019 15:50:11 +0000</created>
                <updated>Sun, 29 Oct 2023 22:24:33 +0000</updated>
                            <resolved>Sat, 30 Mar 2019 03:06:30 +0000</resolved>
                                                    <fixVersion>3.6.15</fixVersion>
                    <fixVersion>4.1.10</fixVersion>
                    <fixVersion>4.0.13</fixVersion>
                                    <component>Querying</component>
                    <component>Replication</component>
                                        <votes>0</votes>
                                    <watches>8</watches>
                                                                                                                <comments>
                            <comment id="2407048" author="xgen-internal-githook" created="Wed, 4 Sep 2019 14:09:20 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;ldennis&apos;, &apos;email&apos;: &apos;lingzhi.deng@mongodb.com&apos;, &apos;name&apos;: &apos;Lingzhi Deng&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-39310&quot; title=&quot;Check canServeReadsFor in getMores&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-39310&quot;&gt;&lt;del&gt;SERVER-39310&lt;/del&gt;&lt;/a&gt;: Call checkCanServeReadsFor() in &apos;getMore&apos;&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;added call to checkCanServeReadsFor() in getmore_cmd.cpp after getting readlocks&lt;/li&gt;
	&lt;li&gt;introduced two fail points: 1. pause &apos;getMore&apos; before readlocks 2. pause rollback after state transition&lt;/li&gt;
	&lt;li&gt;added testcase read_operations_during_rollback.js&lt;/li&gt;
	&lt;li&gt;added call to checkCanServeReadsFor() in find_cmd.cpp after getting readlocks (cherry picked from commit e8fe32029aded4d0e909f531196edff43c96cfff)&lt;/li&gt;
	&lt;li&gt;added assert.includes (cherry picked from commit dd9be1adf2425c7ddd746ff6da75d564474ebed3)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;(cherry picked from commit b885fa6feb7da00dc367e917c53ba16a41b75af4)&lt;br/&gt;
Branch: v3.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/3eb6bc9a15f95473bf666a58be81da1e89cc0837&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/3eb6bc9a15f95473bf666a58be81da1e89cc0837&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2405948" author="xgen-internal-githook" created="Tue, 3 Sep 2019 19:30:36 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Lingzhi Deng&apos;, &apos;username&apos;: &apos;ldennis&apos;, &apos;email&apos;: &apos;lingzhi.deng@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-39310&quot; title=&quot;Check canServeReadsFor in getMores&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-39310&quot;&gt;&lt;del&gt;SERVER-39310&lt;/del&gt;&lt;/a&gt;: Call checkCanServeReadsFor() in &apos;getMore&apos;&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;added call to checkCanServeReadsFor() in getmore_cmd.cpp after getting readlocks&lt;/li&gt;
	&lt;li&gt;introduced two fail points: 1. pause &apos;getMore&apos; before readlocks 2. pause rollback after state transition&lt;/li&gt;
	&lt;li&gt;added testcase read_operations_during_rollback.js&lt;/li&gt;
	&lt;li&gt;added assert.includes (cherry picked from commit dd9be1adf2425c7ddd746ff6da75d564474ebed3)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;(cherry picked from commit b885fa6feb7da00dc367e917c53ba16a41b75af4)&lt;br/&gt;
Branch: v4.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/88df2558b0c3b39b86df2ab97814d701d701d704&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/88df2558b0c3b39b86df2ab97814d701d701d704&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2381407" author="suganthi.mani" created="Wed, 21 Aug 2019 18:19:59 +0000"  >&lt;p&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;, your understanding is correct. I shouldn&apos;t have used the word safe in my above comment. Backports would be for optimization purpose.&lt;/p&gt;</comment>
                            <comment id="2196350" author="shane.harvey" created="Fri, 29 Mar 2019 18:21:55 +0000"  >&lt;p&gt;Perfect, thanks Judah!&lt;/p&gt;</comment>
                            <comment id="2195754" author="judah.schvimer" created="Fri, 29 Mar 2019 12:04:09 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=shane.harvey&quot; class=&quot;user-hover&quot; rel=&quot;shane.harvey&quot;&gt;shane.harvey&lt;/a&gt;, I wouldn&apos;t expect this to have any impact on stepdown since &lt;tt&gt;canServeReadsFor&lt;/tt&gt; is still true as a secondary. This should only impact nodes going into rollback, recovering, or removed states.&lt;/p&gt;</comment>
                            <comment id="2195353" author="shane.harvey" created="Thu, 28 Mar 2019 22:17:04 +0000"  >&lt;p&gt;Does this have any impact on the &quot;cursors survive primary stepdown&quot; goal in &lt;a href=&quot;https://jira.mongodb.org/browse/DRIVERS-552&quot; title=&quot;Connections survive primary stepdown&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DRIVERS-552&quot;&gt;&lt;del&gt;DRIVERS-552&lt;/del&gt;&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;I&apos;m wondering if this change could break drivers that send the cursor&apos;s original read preference with getMores. CC: &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=oleg.pudeyev&quot; class=&quot;user-hover&quot; rel=&quot;oleg.pudeyev&quot;&gt;oleg.pudeyev&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="2195212" author="xgen-internal-githook" created="Thu, 28 Mar 2019 20:38:41 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Lingzhi Deng&apos;, &apos;username&apos;: &apos;ldennis&apos;, &apos;email&apos;: &apos;lingzhi.deng@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-39310&quot; title=&quot;Check canServeReadsFor in getMores&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-39310&quot;&gt;&lt;del&gt;SERVER-39310&lt;/del&gt;&lt;/a&gt;: Call checkCanServeReadsFor() in &apos;getMore&apos;&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;added call to checkCanServeReadsFor() in getmore_cmd.cpp after getting readlocks&lt;/li&gt;
	&lt;li&gt;introduced two fail points: 1. pause &apos;getMore&apos; before readlocks 2. pause rollback after state transition&lt;/li&gt;
	&lt;li&gt;added testcase read_operations_during_rollback.js&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/b885fa6feb7da00dc367e917c53ba16a41b75af4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/b885fa6feb7da00dc367e917c53ba16a41b75af4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="2188626" author="lingzhi.deng" created="Fri, 22 Mar 2019 14:57:15 +0000"  >&lt;p&gt;Posting my findings here:&lt;br/&gt;
When a node transitions to ROLLBACK, it also kills all ongoing connections under the Transition Lock Guard. And if a client reconnects and issues a &quot;getMore&quot; command, execCommandDatabase() will catch it at &lt;a href=&quot;https://github.com/mongodb/mongo/blob/4f32712/src/mongo/db/service_entry_point_common.cpp#L701&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;. So I think we are safe.&lt;/p&gt;

&lt;p&gt;I agree that we should be consistent with &quot;find&quot; and I have made that change. I also added a test case to make sure we do kill all ongoing connections. The test also exercises checkCanServeReadsFor() in both &quot;find&quot; and &quot;getMore&quot; codepath with and without skipCheckingForNotMasterInCommandDispatch fail point. Previously without the check in &quot;getMore&quot;, the test would fail if we enable&#160;skipCheckingForNotMasterInCommandDispatch.&lt;/p&gt;

&lt;p&gt;I am about to open a cr for that once it passes evergreen.&lt;/p&gt;</comment>
                            <comment id="2136507" author="david.storch" created="Mon, 4 Feb 2019 14:42:31 +0000"  >&lt;p&gt;Adding some details per the request of &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;.&lt;/p&gt;

&lt;p&gt;The getMore command is completely missing a call to&#160;canServeReadsFor(), which is the bug tracked by this ticket. The OP_GET_MORE path, in contrast, appears to be implemented correctly. Note that in&#160;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/f4656acfee11569a796e06d14e4825ab54d39ecc/src/mongo/db/query/find.cpp#L291-L327&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this block of code&lt;/a&gt;, we only call canServeReadsFor() if the LockPolicy associated with the cursor is &lt;em&gt;not&lt;/em&gt; &apos;kLocksInternally&apos;. For aggregate cursors, getMore/OP_GET_MORE do not take locks themselves, so checkCanServeReadsFor() cannot be called here.&#160;However, it looks like the place where we do eventually acquire a lock during agg execution remembers to call checkCanServeReadsFor(): see&#160;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/9606de0f0f3166b9c8fcff033f2476af2937f685/src/mongo/db/pipeline/document_source_cursor.cpp#L93-L94&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/9606de0f0f3166b9c8fcff033f2476af2937f685/src/mongo/db/pipeline/document_source_cursor.cpp#L93-L94&lt;/a&gt;. Therefore, both &apos;kLocksInternally&apos; and &apos;kLockExternally&apos; cursors have the necessary canServeReadsFor() check for OP_GET_MORE. &apos;kLockExternally&apos; cursors with getMore command is flawed.&lt;/p&gt;</comment>
                            <comment id="2133648" author="judah.schvimer" created="Thu, 31 Jan 2019 17:51:24 +0000"  >&lt;p&gt;This would only lead to returning inconsistent data in a getMore, though a getMore on the oplog should not hit this. Thus a secondary would not have duplicate _id&apos;s due to this bug. I think this is a beginning of time bug, though we&apos;d have to create a repro and test it to confirm.&lt;/p&gt;</comment>
                            <comment id="2133461" author="bruce.lucas@10gen.com" created="Thu, 31 Jan 2019 15:56:44 +0000"  >&lt;p&gt;What versions does this affect? What are the possible user-visible consequences? For example, could this lead to duplicate _id&apos;s on the secondary?&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">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </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_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="15640"><![CDATA[v4.0]]></customfieldvalue>
    <customfieldvalue key="15141"><![CDATA[v3.6]]></customfieldvalue>
    <customfieldvalue key="14340"><![CDATA[v3.4]]></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, 31 Jan 2019 15:56:44 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 23 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>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, 23 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.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>bruce.lucas@mongodb.com</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>judah.schvimer@mongodb.com</customfieldvalue>
            <customfieldvalue>lingzhi.deng@mongodb.com</customfieldvalue>
            <customfieldvalue>shane.harvey@mongodb.com</customfieldvalue>
            <customfieldvalue>suganthi.mani@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hukrpr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hu47yv:</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="2823">Repl 2019-03-25</customfieldvalue>
    <customfieldvalue id="2896">Repl 2019-04-08</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|hukdz3:</customfieldvalue>

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