<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:34:46 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-77185] Bug with implementation of $lookup in SBE</title>
                <link>https://jira.mongodb.org/browse/SERVER-77185</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://parsley.mongodb.com/resmoke/881fbc6b87d5bed8f95527de86abd954/all?bookmarks=0,80180&amp;amp;shareLine=73970&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://parsley.mongodb.com/resmoke/881fbc6b87d5bed8f95527de86abd954/all?bookmarks=0,80180&amp;amp;shareLine=73970&lt;/a&gt;&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;ASSERT   4457000 [conn36] &quot;Tripwire assertion&quot;,&quot;attr&quot;:{&quot;error&quot;:{&quot;code&quot;:6373900,&quot;codeName&quot;:&quot;Location6373900&quot;,&quot;errmsg&quot;:&quot;bufferIdx not found in record store&quot;},&quot;location&quot;:&quot;{fileName:\&quot;src/mongo/db/exec/sbe/stages/hash_lookup.cpp\&quot;, line:432, functionName:\&quot;operator()\&quot;}&quot;}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Sending to Query Execution per &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mihai.andrei%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;mihai.andrei@mongodb.com&quot;&gt;mihai.andrei@mongodb.com&lt;/a&gt;.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2342511">SERVER-77185</key>
            <summary>Bug with implementation of $lookup in SBE</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="ivan.fefer@mongodb.com">Ivan Fefer</assignee>
                                    <reporter username="felipe.gasper@mongodb.com">Felipe Gasper</reporter>
                        <labels>
                    </labels>
                <created>Tue, 16 May 2023 16:10:03 +0000</created>
                <updated>Sun, 29 Oct 2023 21:21:24 +0000</updated>
                            <resolved>Wed, 31 May 2023 09:51:08 +0000</resolved>
                                    <version>6.0.6</version>
                                    <fixVersion>7.1.0-rc0</fixVersion>
                    <fixVersion>6.0.7</fixVersion>
                    <fixVersion>7.0.0-rc4</fixVersion>
                                                        <votes>0</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="5491627" author="xgen-internal-githook" created="Mon, 12 Jun 2023 12:59:16 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Ivan Fefer&apos;, &apos;email&apos;: &apos;ivan.fefer@mongodb.com&apos;, &apos;username&apos;: &apos;Fefer-Ivan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-77185&quot; title=&quot;Bug with implementation of $lookup in SBE&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-77185&quot;&gt;&lt;del&gt;SERVER-77185&lt;/del&gt;&lt;/a&gt; Fix incorrect buffer indexing in case of spilling in hash lookup&lt;br/&gt;
Branch: v7.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/373210451367852927bc7ba2a9e4e8b2083e236d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/373210451367852927bc7ba2a9e4e8b2083e236d&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5491584" author="xgen-internal-githook" created="Mon, 12 Jun 2023 12:44:07 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Ivan Fefer&apos;, &apos;email&apos;: &apos;ivan.fefer@mongodb.com&apos;, &apos;username&apos;: &apos;Fefer-Ivan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-77185&quot; title=&quot;Bug with implementation of $lookup in SBE&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-77185&quot;&gt;&lt;del&gt;SERVER-77185&lt;/del&gt;&lt;/a&gt; Fix incorrect buffer indexing in case of spilling in hash lookup&lt;br/&gt;
Branch: v6.0&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/82f5a7b1df90c2b320fe67daf49ceb127944aaaf&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/82f5a7b1df90c2b320fe67daf49ceb127944aaaf&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5461373" author="xgen-internal-githook" created="Tue, 30 May 2023 18:12:00 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Ivan Fefer&apos;, &apos;email&apos;: &apos;ivan.fefer@mongodb.com&apos;, &apos;username&apos;: &apos;Fefer-Ivan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-77185&quot; title=&quot;Bug with implementation of $lookup in SBE&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-77185&quot;&gt;&lt;del&gt;SERVER-77185&lt;/del&gt;&lt;/a&gt; Fix incorrect buffer indexing in case of spilling in hash lookup&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/9adbd8f24d7b232943d560b2969580cd6ca97893&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/9adbd8f24d7b232943d560b2969580cd6ca97893&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5447914" author="JIRAUSER1270969" created="Wed, 24 May 2023 09:45:57 +0000"  >&lt;p&gt;The bug is in buffered value spilling condition: &lt;a href=&quot;https://github.com/mongodb/mongo/blob/ecf5b575b936f7bbf6d9b3a581a18760e6450ab3/src/mongo/db/exec/sbe/stages/hash_lookup.cpp#L343&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/ecf5b575b936f7bbf6d9b3a581a18760e6450ab3/src/mongo/db/exec/sbe/stages/hash_lookup.cpp#L343&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HashLookup has _buffer vector in-memory and spilled RecordStore for the rest of the values.&lt;br/&gt;
When building the hash table, we number buffered values from 0 to N.&lt;br/&gt;
We assume that first M numbers fit in memory and then we spill.&lt;br/&gt;
For example, here we want to get buffered value _bufferIt, we check if _bufferIt &amp;lt; _buffer.size() and look in memory. Otherwise, we go to the RecordStore:&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/blob/ecf5b575b936f7bbf6d9b3a581a18760e6450ab3/src/mongo/db/exec/sbe/stages/hash_lookup.cpp#L426&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/ecf5b575b936f7bbf6d9b3a581a18760e6450ab3/src/mongo/db/exec/sbe/stages/hash_lookup.cpp#L426&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we start spilling, we should always spill. Otherwise there is this bug:&lt;br/&gt;
Imagine we have to buffer three values: small_0, big_1, small_2. Small_0 and small_2 fit together in RAM, but big have to be spilled.&lt;br/&gt;
Current code will do the following:&lt;br/&gt;
1. Add small_0 to _buffer.&lt;br/&gt;
2. See that small_0 + big_1 do not fit and spill big.&lt;br/&gt;
3. See that small_0 + small_2 fit and will add small_2 to _buffer.&lt;br/&gt;
We will end up with _buffer.size() == 2 with small_0 and small_2 and spilled RecordStore with RID 1 with big_1.&lt;br/&gt;
This is wrong.&lt;/p&gt;

&lt;p&gt;There are actually two bugs:&#160;&lt;br/&gt;
1. When looking for big_1, we will check that 1 &amp;lt; _buffer.size() and return _buffer&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt; == small_2.&lt;br/&gt;
2. When looking for small_2 we will check that 2 &amp;gt;= _buffer.size() and look it up in RecordStore, but it won&apos;t be there.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;I will fix the bug, add a regression test.&lt;/p&gt;



&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="5447840" author="JIRAUSER1270969" created="Wed, 24 May 2023 09:08:32 +0000"  >&lt;p&gt;I was able to reproduce the issue.&lt;br/&gt;
Looks like a bug around missing/null lookup fields.&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>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                                        </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.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_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25125"><![CDATA[Query Execution]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25578"><![CDATA[v7.0]]></customfieldvalue>
    <customfieldvalue key="25376"><![CDATA[v6.3]]></customfieldvalue>
    <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>Wed, 24 May 2023 09:08:32 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        34 weeks, 2 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_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>
                            34 weeks, 2 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>felipe.gasper@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>ivan.fefer@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i29h9r:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i1rr3c:</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="7233">QE 2023-05-29</customfieldvalue>
    <customfieldvalue id="7236">QE 2023-06-12</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Unknown; this was a BF from mongosync. These can be hard to reproduce, unfortunately.&lt;/p&gt;</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|i293f3:</customfieldvalue>

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