<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:33:00 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-76559] Lock-free reads can read from sharded collection as unsharded when collection is dropped and recreated (ABA problem)</title>
                <link>https://jira.mongodb.org/browse/SERVER-76559</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;This is hypothetical, we haven&apos;t tried to reproduce it.&lt;/p&gt;

&lt;p&gt;The scenario looks like this:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Collection exists and is unsharded.&lt;/li&gt;
	&lt;li&gt;Mongos attaches shard version UNSHARDED to the request.&lt;/li&gt;
	&lt;li&gt;Collection becomes sharded from some other client running shardCollection.&lt;/li&gt;
	&lt;li&gt;AutoGetCollectionLockFree opens the snapshot at this point.&lt;/li&gt;
	&lt;li&gt;Collection is dropped from some other client running drop.&lt;/li&gt;
	&lt;li&gt;Collection is created again as unsharded from some other client running create.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/10gen/mongo/blob/9ddfa200ab0a5a80c3c2996f8ef325d91eaf35ce/src/mongo/db/db_raii.cpp#L988-L996&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AutoGetCollectionForReadCommandLockFree checks and sees the collection is unsharded&lt;/a&gt;. Then &lt;a href=&quot;https://github.com/10gen/mongo/blob/9ddfa200ab0a5a80c3c2996f8ef325d91eaf35ce/src/mongo/db/db_raii.cpp#L1067-L1070&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AutoGetCollectionForReadCommandBase checks the shard version&lt;/a&gt; and everything checks out. In particular, CollectionShardingState::checkShardVersionOrThrow() passes because the request was sent with shard version UNSHARDED and the collection &lt;em&gt;is&lt;/em&gt; (again now) unsharded.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Currently &lt;a href=&quot;https://github.com/mongodb/mongo/blob/788248b98798044e325f30402ec3812a80dfbaf1/src/mongo/db/db_raii.cpp#L1082-L1105&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;we have a check&lt;/a&gt; to prevent this exact scenario described in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-62457&quot; title=&quot;Lock-free reads causes query subsystem to treat unsharded collection as sharded when collection is dropped and re-created (ABA problem)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-62457&quot;&gt;&lt;del&gt;SERVER-62457&lt;/del&gt;&lt;/a&gt; , however it relies on the check in &lt;a href=&quot;https://github.com/10gen/mongo/blob/9ddfa200ab0a5a80c3c2996f8ef325d91eaf35ce/src/mongo/db/db_raii.cpp#L988-L996&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;AutoGetCollectionForReadCommandLockFree&lt;/a&gt; to observe the collection as sharded, if the check happens when the collection is unsharded again the problem is not detected (presumably).&lt;/p&gt;</description>
                <environment></environment>
        <key id="2324925">SERVER-76559</key>
            <summary>Lock-free reads can read from sharded collection as unsharded when collection is dropped and recreated (ABA problem)</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="henrik.edin@mongodb.com">Henrik Edin</assignee>
                                    <reporter username="daniel.gomezferro@mongodb.com">Daniel Gomez Ferro</reporter>
                        <labels>
                    </labels>
                <created>Wed, 26 Apr 2023 16:25:55 +0000</created>
                <updated>Fri, 9 Jun 2023 17:50:00 +0000</updated>
                            <resolved>Fri, 9 Jun 2023 17:50:00 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="5488791" author="henrik.edin" created="Fri, 9 Jun 2023 17:50:00 +0000"  >&lt;p&gt;After discussing with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kaloian.manassiev%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;kaloian.manassiev@mongodb.com&quot;&gt;kaloian.manassiev@mongodb.com&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=daniel.gomezferro%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;daniel.gomezferro@mongodb.com&quot;&gt;daniel.gomezferro@mongodb.com&lt;/a&gt; we will close this as Won&apos;t Fix as this ticket relates to the old AutoGet*** handlers. We want to fix it in the new Acquisitions classes but this work is tracked in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-76561&quot; title=&quot;Lock-free acquisitions can read from sharded collection as unsharded when collection is dropped and recreated (ABA problem)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-76561&quot;&gt;SERVER-76561&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="5395742" author="dianna.hohensee" created="Tue, 2 May 2023 21:05:23 +0000"  >&lt;p&gt;I think this can happen. I haven&apos;t tested it, just logically walking through what I know. But it involves a user querying a collection while concurrently serially issuing shardCollection, dropCollection, createCollection cmds. The user will end up reading from the original version of the collection without shard filtering (a routing table). I think this is a perfectly OK result for the user given the concurrency involved. The only way it might not be OK would be if the collection were sharded, moveChunk redistributed the data away from the shard and then the collection is dropped/recreated, all in a very small window of time. I think it is a very unlikely user scenario with moveChunk, but it&apos;s definitely a loophole we should close sometime &#8211; after verifying the scenario is reproducible.&lt;/p&gt;

&lt;p&gt;In the master code, the shardCollection can happen anytime after the mongos sends the query against the mongod and before the mongod &lt;a href=&quot;https://github.com/10gen/mongo/blob/9ddfa200ab0a5a80c3c2996f8ef325d91eaf35ce/src/mongo/db/db_raii.cpp#L965&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;opens the storage snapshot&lt;/a&gt; and then drop/recreate must happen after the snapshot but before &lt;a href=&quot;https://github.com/10gen/mongo/blob/9ddfa200ab0a5a80c3c2996f8ef325d91eaf35ce/src/mongo/db/db_raii.cpp#L988-L996&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the isSharded check&lt;/a&gt;. In v6.0, all the commands must run between &lt;a href=&quot;https://github.com/mongodb/mongo/blob/e0107b4cf5674ab8b9c4b1c35d7310f9d2db1819/src/mongo/db/catalog_raii.cpp#L422-L426&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the isSharded check prior to opening the storage snapshot&lt;/a&gt; and &lt;a href=&quot;https://github.com/mongodb/mongo/blob/v6.0/src/mongo/db/db_raii.cpp#L824-L828&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;checking the SV right after establishing a storage snapshot&lt;/a&gt;. It&apos;s a good bit more likely in master/7.0, actually, if I&apos;ve analyzed this correctly.&lt;/p&gt;

&lt;p&gt;In retrospect, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-62457&quot; title=&quot;Lock-free reads causes query subsystem to treat unsharded collection as sharded when collection is dropped and re-created (ABA problem)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-62457&quot;&gt;&lt;del&gt;SERVER-62457&lt;/del&gt;&lt;/a&gt; does seem to have addressed a particular scenario where our code could hit an invariant in the query stage using LFR.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2324948">SERVER-76561</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25136"><![CDATA[Storage Execution]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 2 May 2023 21:05:23 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        34 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_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>henrik.edin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            34 weeks, 5 days ago
                        </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>daniel.gomezferro@mongodb.com</customfieldvalue>
            <customfieldvalue>dianna.hohensee@mongodb.com</customfieldvalue>
            <customfieldvalue>henrik.edin@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i26gs7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i1rwmv:r</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="7176">Execution Team 2023-05-15</customfieldvalue>
    <customfieldvalue id="7177">Execution Team 2023-05-29</customfieldvalue>
    <customfieldvalue id="7179">Execution NAMR Team 2023-06-26</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|i262xj:</customfieldvalue>

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