<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:19:29 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-28943] Make shards retry non-write commands on stale version exceptions</title>
                <link>https://jira.mongodb.org/browse/SERVER-28943</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If a shard encounters a shardVersion mismatch in checkShardVersionOrThrow, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.5.6/src/mongo/db/s/collection_sharding_state.cpp#L350-L375&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;it returns a stale version error even if the sender was more fresh&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When a shard is returning a stale version error, it also refreshes its own routing table just before sending the response.&lt;/p&gt;

&lt;p&gt;In the case the mongos was more fresh, the mongos is forced to refresh its routing table cache and send the request again. Then, since the shard refreshed just before responding, the shard will accept the request (unless another migration/dropCollection/unshardCollection has happened).&lt;/p&gt;

&lt;p&gt;This wastes two network round-trips: the mongos has to refresh from the config servers even though it&apos;s not stale, and the mongos has to re-send the request to the shard.&lt;/p&gt;

&lt;p&gt;It would be better if the shard refreshed and re-tried checkShardVersionOrThrow, and only responded with a stale version error if the sender was more stale.&lt;/p&gt;

&lt;p&gt;This is an improvement/optimization and not that easy of a change, since the collection is locked when checkShardVersionOrThrow is called (so we can&apos;t simply move the shard&apos;s routing table refresh to checkShardVersionOrThrow).&lt;/p&gt;</description>
                <environment></environment>
        <key id="377070">SERVER-28943</key>
            <summary>Make shards retry non-write commands on stale version exceptions</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="tommaso.tocci@mongodb.com">Tommaso Tocci</assignee>
                                    <reporter username="esha.maharishi@mongodb.com">Esha Maharishi</reporter>
                        <labels>
                            <label>PM-1965-Cleanup</label>
                    </labels>
                <created>Mon, 24 Apr 2017 19:40:06 +0000</created>
                <updated>Mon, 30 Oct 2023 23:17:14 +0000</updated>
                            <resolved>Wed, 11 Nov 2020 18:34:50 +0000</resolved>
                                    <version>3.2.12</version>
                    <version>3.4.4</version>
                    <version>3.5.6</version>
                                    <fixVersion>4.9.0</fixVersion>
                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="3485910" author="xgen-internal-githook" created="Wed, 11 Nov 2020 18:15:18 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Tommaso Tocci&apos;, &apos;email&apos;: &apos;tommaso.tocci@mongodb.com&apos;, &apos;username&apos;: &apos;toto-dev&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-28943&quot; title=&quot;Make shards retry non-write commands on stale version exceptions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-28943&quot;&gt;&lt;del&gt;SERVER-28943&lt;/del&gt;&lt;/a&gt; Make shards retry non-write commands on stale version exceptions&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/3eabee611446687824c2560ab78dc51e57b91d75&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/3eabee611446687824c2560ab78dc51e57b91d75&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3472003" author="tommaso.tocci" created="Mon, 2 Nov 2020 17:06:21 +0000"  >&lt;p&gt;I&apos;m re-opening this because during skunkwork project I&apos;ve implemented the retry logic on the shards for non-write commands.&lt;/p&gt;</comment>
                            <comment id="3470766" author="esha.maharishi@10gen.com" created="Sun, 1 Nov 2020 17:28:01 +0000"  >&lt;p&gt;This is an old cleanup ticket that wouldn&apos;t be scheduled independently. It may get done as part of other work.&lt;/p&gt;</comment>
                            <comment id="1743277" author="dianna.hohensee" created="Tue, 5 Dec 2017 18:32:28 +0000"  >&lt;p&gt;Putting this is PM-675, because this will lead to the mongos needing to re-establish shard point-in-time reads less often &amp;#8211; the assumption here is that if a mongos receives a StaleShardVersion error from one shard, it must resend to all shards in order to ensure every shard is using the correct filtering metadata for that point in time.&lt;/p&gt;</comment>
                            <comment id="1597912" author="xgen-internal-githook" created="Thu, 15 Jun 2017 13:39:03 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;EshaMaharishi&apos;, u&apos;name&apos;: u&apos;Esha Maharishi&apos;, u&apos;email&apos;: u&apos;esha.maharishi@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-28943&quot; title=&quot;Make shards retry non-write commands on stale version exceptions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-28943&quot;&gt;&lt;del&gt;SERVER-28943&lt;/del&gt;&lt;/a&gt; increase stale version retries from 3 to 10&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/4af14770aa104cf86592fa97cc9e5878be74b096&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/4af14770aa104cf86592fa97cc9e5878be74b096&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1592329" author="esha.maharishi@10gen.com" created="Fri, 9 Jun 2017 15:49:31 +0000"  >&lt;p&gt;Temporary workaround will be to bump the retries from 3 to 10 in scatterGather().&lt;/p&gt;</comment>
                            <comment id="1578019" author="esha.maharishi@10gen.com" created="Tue, 23 May 2017 18:12:02 +0000"  >&lt;p&gt;Note, one way to implement this could be to wrap all paths on mongod that call onStaleShardVersion() in a loop, to allow the whole operation to be retried (not just retrying the shardVersion check).&lt;/p&gt;

&lt;p&gt;This is fairly straightforward (at least code-changes wise; not sure what the side-effects might be, especially for non-idempotent operations) for finds over OP_QUERY and other non-write commands:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;finds over OP_QUERY: onStaleShardVersion() is &lt;a href=&quot;https://github.com/mongodb/mongo/blob/8edbf46a78494ae034e8faa982c8f8bdcd5c3ef4/src/mongo/db/assemble_response.cpp#L351-L352&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;called in receivedQuery&lt;/a&gt;, and that try-catch could just be put in a loop&lt;/li&gt;
	&lt;li&gt;other non-write commands: onStaleShardVersion() is &lt;a href=&quot;https://github.com/mongodb/mongo/blob/8edbf46a78494ae034e8faa982c8f8bdcd5c3ef4/src/mongo/db/run_commands.cpp#L649-L650&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;called in execCommandDatabase&lt;/a&gt;, and this try-catch could also be put in a loop, though the try-catch is longer so there might be complications&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Write commands might be more difficult, since onStaleShardVersion() is &lt;a href=&quot;https://github.com/mongodb/mongo/blob/8edbf46a78494ae034e8faa982c8f8bdcd5c3ef4/src/mongo/db/ops/write_ops_exec.cpp#L222-L223&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;called in handleError()&lt;/a&gt;, which is called in multiple places.&lt;/p&gt;</comment>
                            <comment id="1578005" author="esha.maharishi@10gen.com" created="Tue, 23 May 2017 18:02:08 +0000"  >&lt;p&gt;Putting this back into Needs Triage, as it is the preferred fix for the linked BF-5311 (see the &lt;a href=&quot;https://jira.mongodb.org/browse/BF-5311?focusedCommentId=1577999&amp;amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-1577999&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;comment&lt;/a&gt; on that BF).&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                        <issuelink>
            <issuekey id="1728942">SERVER-57051</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="393923">SERVER-29630</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>8.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="10011"><![CDATA[Minor Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 15 Jun 2017 13:39:03 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 13 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_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-1965</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>
                            3 years, 13 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>dianna.hohensee@mongodb.com</customfieldvalue>
            <customfieldvalue>esha.maharishi@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>tommaso.tocci@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|ht6bm7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrakon:</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="4255">Sharding 2020-11-02</customfieldvalue>
    <customfieldvalue id="4256">Sharding 2020-11-16</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|hs4a2v:</customfieldvalue>

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