<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:57:07 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-41214] Query yield recovery does not check for collection rename under the correct locks</title>
                <link>https://jira.mongodb.org/browse/SERVER-41214</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Queries periodically yield and recover their intent locks using &lt;tt&gt;Locker::LockSnapshot&lt;/tt&gt;. After &lt;a href=&quot;https://github.com/mongodb/mongo/blob/0dea5729cd3cf2fb219aeeb7fdbbdfa58c8c7bb3/src/mongo/db/query/plan_yield_policy.cpp#L205&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;restoring the lock snapshot&lt;/a&gt;, &lt;tt&gt;PlanExecutor::restoreState()&lt;/tt&gt; is called in order to make several validity checks. As part of this yield recovery process, we make a &lt;a href=&quot;https://github.com/mongodb/mongo/blob/0dea5729cd3cf2fb219aeeb7fdbbdfa58c8c7bb3/src/mongo/db/exec/requires_collection_stage.cpp#L61-L68&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;check for collection rename&lt;/a&gt; and throw an exception if the &lt;tt&gt;Collection&lt;/tt&gt; object&apos;s namespace string has changed during yield.&lt;/p&gt;

&lt;p&gt;It is possible that this check is made without holding the correct lock on the &lt;tt&gt;Collection&lt;/tt&gt; object. The resource IDs which we lock are collection names, not collection UUIDs. Therefore, if a collection is renamed, the identity of the lock that must be held to protect the &lt;tt&gt;Collection&lt;/tt&gt; object also changes. Consider the case of a collection being renamed from &lt;em&gt;A&lt;/em&gt; to &lt;em&gt;B&lt;/em&gt; during yield. When the lock snapshot is restored, the query execution subsystem will continue to hold the lock on &lt;em&gt;A&lt;/em&gt;, not &lt;em&gt;B&lt;/em&gt;. This means that the call to &lt;tt&gt;Collection::ns()&lt;/tt&gt; may not be correctly synchronized with other threads executing drops or renames on that collection.&lt;/p&gt;

&lt;p&gt;Credit to &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=geert.bosch&quot; class=&quot;user-hover&quot; rel=&quot;geert.bosch&quot;&gt;geert.bosch&lt;/a&gt; for helping me discover this issue and think through a fix. The easiest fix would be to use &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1d1a7182c70a4c13782af9a60067cac5008ca3c6/src/mongo/db/catalog/collection_catalog.h#L214&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CollectionCatalog::lookupNSSByUUID()&lt;/a&gt; instead of &lt;a href=&quot;https://github.com/mongodb/mongo/blob/1d1a7182c70a4c13782af9a60067cac5008ca3c6/src/mongo/db/catalog/collection_catalog.h#L177&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CollectionCatalog::lookupCollectionByUUID()&lt;/a&gt; in order to safely identify whether a rename has occurred. If the namespace string has not changed, then you know that the correct locks were restored from the lock snapshot and query execution can proceed. Otherwise, the query will be killed.&lt;/p&gt;

&lt;p&gt;Additional work will be required if we ever want to allow queries to survive renames. In particular, we may want to change query yielding so that it doesn&apos;t use the &lt;tt&gt;Locker::LockSnapshot&lt;/tt&gt; interface, but rather uses the db_raii.h helpers directly on yield recovery.&lt;/p&gt;</description>
                <environment></environment>
        <key id="770937">SERVER-41214</key>
            <summary>Query yield recovery does not check for collection rename under the correct locks</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="david.storch@mongodb.com">David Storch</assignee>
                                    <reporter username="david.storch@mongodb.com">David Storch</reporter>
                        <labels>
                            <label>query-44-grooming</label>
                    </labels>
                <created>Fri, 17 May 2019 17:41:08 +0000</created>
                <updated>Sun, 29 Oct 2023 22:20:54 +0000</updated>
                            <resolved>Wed, 26 Jun 2019 16:26:46 +0000</resolved>
                                                    <fixVersion>4.2.0-rc3</fixVersion>
                    <fixVersion>4.3.1</fixVersion>
                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="2298847" author="xgen-internal-githook" created="Wed, 26 Jun 2019 19:53:30 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;David Storch&apos;, &apos;username&apos;: &apos;dstorch&apos;, &apos;email&apos;: &apos;david.storch@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41214&quot; title=&quot;Query yield recovery does not check for collection rename under the correct locks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41214&quot;&gt;&lt;del&gt;SERVER-41214&lt;/del&gt;&lt;/a&gt; Fix data race in restoring PlanStages which require a collection.&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 7717e2f424e3bdf1e70bb21f25f39f5a2081bf26)&lt;br/&gt;
Branch: v4.2&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/06ccd790b6216e0eec525a40e470949213c3df4e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/06ccd790b6216e0eec525a40e470949213c3df4e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2298434" author="xgen-internal-githook" created="Wed, 26 Jun 2019 16:25:53 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;David Storch&apos;, &apos;email&apos;: &apos;david.storch@10gen.com&apos;, &apos;username&apos;: &apos;dstorch&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41214&quot; title=&quot;Query yield recovery does not check for collection rename under the correct locks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41214&quot;&gt;&lt;del&gt;SERVER-41214&lt;/del&gt;&lt;/a&gt; Fix data race in restoring PlanStages which require a collection.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/7717e2f424e3bdf1e70bb21f25f39f5a2081bf26&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/7717e2f424e3bdf1e70bb21f25f39f5a2081bf26&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2298433" author="xgen-internal-githook" created="Wed, 26 Jun 2019 16:25:51 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;David Storch&apos;, &apos;email&apos;: &apos;david.storch@10gen.com&apos;, &apos;username&apos;: &apos;dstorch&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-41214&quot; title=&quot;Query yield recovery does not check for collection rename under the correct locks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-41214&quot;&gt;&lt;del&gt;SERVER-41214&lt;/del&gt;&lt;/a&gt; Modernize COLLSCAN dbtest.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/87b06cc52bd69b40a201e36bdec1e3e912c42277&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/87b06cc52bd69b40a201e36bdec1e3e912c42277&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2296818" author="geert.bosch" created="Tue, 25 Jun 2019 16:25:07 +0000"  >&lt;p&gt;BTW, this would be great:&#160;&#160;&quot;change query yielding so that it doesn&apos;t use the &lt;tt&gt;Locker::LockSnapshot&lt;/tt&gt; interface, but rather uses the db_raii.h helpers directly on yield recovery&quot;.&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>4.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="16775"><![CDATA[v4.2]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 25 Jun 2019 16:25:07 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 33 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_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, 33 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>59.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>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>geert.bosch@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hv00xz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hupbf3:</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="2844">Query 2019-06-17</customfieldvalue>
    <customfieldvalue id="2845">Query 2019-07-01</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|huzn7b:</customfieldvalue>

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