<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:01:49 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-65083] Thread seeing different set of indices can incorrectly re-use an SBE plan cache entry</title>
                <link>https://jira.mongodb.org/browse/SERVER-65083</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;In &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-60066&quot; title=&quot;Implement plan cache invalidation on collection drop&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-60066&quot;&gt;&lt;del&gt;SERVER-60066&lt;/del&gt;&lt;/a&gt; we attempted to build a versioning mechanism for the SBE plan cache. The idea was to encode a monotonically increasing counter in the SBE plan cache key, and bump this counter in the collection catalog whenever an index is dropped or added. This would ensure that all queries seeing the same version of the &lt;tt&gt;Collection&lt;/tt&gt; object would also see the same set of indices, and that any matching SBE plan cache entry would be consistent with this set of indexes.&lt;/p&gt;

&lt;p&gt;However, this implementation did not fully ensure the correct behavior of the SBE plan cache when there are concurrent index builds drops. The problem is that readers may not read at a timestamp prior to the completion of an index build. When this occurs, the index catalog code &lt;a href=&quot;https://github.com/mongodb/mongo/blob/f9bbbfb86db15ac7e4111890447dc46caf5fe4b4/src/mongo/db/catalog/index_catalog.cpp#L74-L77&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;hides the indexes that were not ready at the reader&apos;s timestamp&lt;/a&gt;. Such readers always see the latest &lt;tt&gt;Collection&lt;/tt&gt; object. This creates a situation where two readers can share a &lt;tt&gt;Collection&lt;/tt&gt; version yet see different views of the index catalog.&lt;/p&gt;

&lt;p&gt;The consequence is that an SBE plan cache entry can be incorrectly reused and trip a &lt;tt&gt;tassert()&lt;/tt&gt;. Here is a step-by-step description of one possible scenario:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;A new index is constructed with a minimum visible snapshot timestamp of t2.&lt;/li&gt;
	&lt;li&gt;Around the same time, two read transactions start. Let&apos;s name the readers r1 and r2.&lt;/li&gt;
	&lt;li&gt;r1 decides to read at timestamp t1 such that t1 &amp;lt; t2.&lt;/li&gt;
	&lt;li&gt;r2 decides to read at timestamp t3 such that t3 &amp;gt; t2.&lt;/li&gt;
	&lt;li&gt;r2 chooses a plan using the newly constructed index, which it can see because its read timestamp is greater than the minimum visible snapshot of the index. It caches this plan.&lt;/li&gt;
	&lt;li&gt;For whatever reason, r1 is running more slowly than r3 (e.g. maybe the thread was unscheduled by the operating system). It consults the plan cache and finds the cache entry constructed by r2. However, r1 cannot see the index because it is reading at a time where the index does not exist on disk. The catalog code makes sure to hide such indexes &lt;a href=&quot;https://github.com/mongodb/mongo/blob/ab7ffadb7f0a242842a31b2f12d49b4c2e97d242/src/mongo/db/catalog/index_catalog.cpp#L74-L77&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
	&lt;li&gt;When r1 tries to recover the plan from the cache, it tries to look up the index by name and asserts that the index exist. This assertion trips because the index is not visible in r1&apos;s snapshot.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;We&apos;ve also seen the bug manifest in a slightly different way:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The test kicks off a rebuild of index {b: 1}, which will get committed with a &lt;tt&gt;minValidSnapshot&lt;/tt&gt; of t2.&lt;/li&gt;
	&lt;li&gt;Meanwhile, two readers r1 and r2 start. r1 is reading at a timestamp of t1 &amp;lt; t2 and r2 is reading at a timestamp of t3 &amp;gt; t2.&lt;/li&gt;
	&lt;li&gt;r1 ends up running first, for whatever reason. Because it cannot see the index {b: 1}, there is only one possible query plan.&lt;/li&gt;
	&lt;li&gt;r2 starts running, but this query can see both indexes. It consults the plan cache, finds nothing, and then starts to multiplan.&lt;/li&gt;
	&lt;li&gt;r1 gets far enough along to insert a pinned cache entry. The cache entry is created as pinned because r1 only generates one query plan, and single solution plans are pinned.&lt;/li&gt;
	&lt;li&gt;r2 finishes multi-planning and tries to cache the result. This will override any pre-existing cache entry. At this point, we see a pinned cache entry and trip a tassert().&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="2012476">SERVER-65083</key>
            <summary>Thread seeing different set of indices can incorrectly re-use an SBE plan cache entry</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>
                    </labels>
                <created>Wed, 30 Mar 2022 18:39:35 +0000</created>
                <updated>Sun, 29 Oct 2023 21:40:19 +0000</updated>
                            <resolved>Wed, 20 Apr 2022 01:58:30 +0000</resolved>
                                                    <fixVersion>6.0.0-rc2</fixVersion>
                    <fixVersion>6.1.0-rc0</fixVersion>
                                    <component>Catalog</component>
                    <component>Query Planning</component>
                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="4494418" author="xgen-internal-githook" created="Wed, 20 Apr 2022 15:40:02 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;David Storch&apos;, &apos;email&apos;: &apos;david.storch@mongodb.com&apos;, &apos;username&apos;: &apos;dstorch&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-65083&quot; title=&quot;Thread seeing different set of indices can incorrectly re-use an SBE plan cache entry&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-65083&quot;&gt;&lt;del&gt;SERVER-65083&lt;/del&gt;&lt;/a&gt; Fix SBE plan cache index visibility bug&lt;/p&gt;

&lt;p&gt;(cherry picked from commit 58219cc81297ed4c3a38045c55588fe16d59a53a)&lt;br/&gt;
Branch: v6.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/4ba6b85fcf077e29226404df0ae21ab30d2a80ba&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/4ba6b85fcf077e29226404df0ae21ab30d2a80ba&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4492911" author="xgen-internal-githook" created="Wed, 20 Apr 2022 00:51:23 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;David Storch&apos;, &apos;email&apos;: &apos;david.storch@mongodb.com&apos;, &apos;username&apos;: &apos;dstorch&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-65083&quot; title=&quot;Thread seeing different set of indices can incorrectly re-use an SBE plan cache entry&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-65083&quot;&gt;&lt;del&gt;SERVER-65083&lt;/del&gt;&lt;/a&gt; Fix SBE plan cache index visibility bug&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/58219cc81297ed4c3a38045c55588fe16d59a53a&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/58219cc81297ed4c3a38045c55588fe16d59a53a&lt;/a&gt;&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">
                                        <issuelink>
            <issuekey id="1996632">SERVER-64315</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2169578">SERVER-70935</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1878077">SERVER-60066</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>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_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23470"><![CDATA[v6.0]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 7 Apr 2022 20:27:58 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 42 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-2371</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 42 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>42.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>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|i0p4d3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i084ak:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_22250" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Special Downgrade Instructions Required</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23343"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="5281">QE 2022-04-04</customfieldvalue>
    <customfieldvalue id="5888">QE 2022-04-18</customfieldvalue>
    <customfieldvalue id="5890">QE 2022-05-02</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|i0oqif:</customfieldvalue>

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