<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:20:06 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-49506] Excessive memory being used in pipelines with deeply nested documents</title>
                <link>https://jira.mongodb.org/browse/SERVER-49506</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Included are memory allocations flamegraphs showing a pair of aggregations with deeply nested documents and $redact&#160; using 35GB of memory or 18.5GB each.&lt;/p&gt;

&lt;p&gt;I do not have the exact aggregation and example document(s) to reproduce this issue, but I believe deeply nested documents with $redact should show similar issues.&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1409295">SERVER-49506</key>
            <summary>Excessive memory being used in pipelines with deeply nested documents</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="3">Duplicate</resolution>
                                        <assignee username="ian.boros@mongodb.com">Ian Boros</assignee>
                                    <reporter username="kevin.arhelger@mongodb.com">Kevin Arhelger</reporter>
                        <labels>
                            <label>qexec-team</label>
                    </labels>
                <created>Tue, 14 Jul 2020 21:08:28 +0000</created>
                <updated>Tue, 6 Oct 2020 17:19:44 +0000</updated>
                            <resolved>Tue, 6 Oct 2020 17:19:25 +0000</resolved>
                                    <version>4.2.2</version>
                                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>10</watches>
                                                                                                                <comments>
                            <comment id="3428765" author="ian.boros" created="Tue, 6 Oct 2020 17:18:44 +0000"  >&lt;p&gt;After discussion with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kevin.arhelger&quot; class=&quot;user-hover&quot; rel=&quot;kevin.arhelger&quot;&gt;kevin.arhelger&lt;/a&gt; we&apos;ve agreed that this is likely a duplicate of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40317&quot; title=&quot;$facet execution has no limit on how much memory it can consume&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40317&quot;&gt;&lt;del&gt;SERVER-40317&lt;/del&gt;&lt;/a&gt; so I am closing as such.&lt;/p&gt;</comment>
                            <comment id="3428606" author="ian.boros" created="Tue, 6 Oct 2020 16:23:52 +0000"  >&lt;p&gt;Correction to my last comment: the document caching only exists in 4.4 and later, so I would not expect the $redact to actually blow up memory usage in the way I described. The memory usage bug with $facet is the most likely explanation here. As mentioned, see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40317&quot; title=&quot;$facet execution has no limit on how much memory it can consume&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40317&quot;&gt;&lt;del&gt;SERVER-40317&lt;/del&gt;&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;I was unable to access the logs in the support case as it looks like they&apos;ve been deleted (attempts to access them result in &quot;The specified key does not exist&quot;).&lt;/p&gt;</comment>
                            <comment id="3418773" author="ian.boros" created="Wed, 30 Sep 2020 15:38:41 +0000"  >&lt;p&gt;My guess is that the issue here is the combination of $redact, a blocking stage (both sort and group appear after the $redact in the flamegraph), and $facet.&lt;/p&gt;

&lt;p&gt;For some context, $redact &lt;a href=&quot;https://github.com/mongodb/mongo/blob/3b8dfefeb9809a826354460b653b9d964730a18a/src/mongo/db/pipeline/document_source_redact.cpp#L147-L156&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;walks the input document&lt;/a&gt;, which brings each field into the Document&apos;s cache. It then builds a a new document using &lt;tt&gt;MutableDocument&lt;/tt&gt; which is fully cached. We know from prior experience that the memory usage of a fully cached Document is far more than that of a plain BSON object because of all of the overhead involved in maintaining the Document&apos;s structure (pointers to children, the document&apos;s hash table, etc). A fully cached document could be 3-4x the size of the BSON object that it represents. Putting a lot of fully cached documents into a blocking stage could certainly cause a lot of memory usage.&lt;/p&gt;

&lt;p&gt;I also see in the flame graph use of DocumentSourceFacet ($facet). For a while, $facet did not enforce any limit on its total memory usage. My understanding is that while there were limits about the size of an individual document, $facet would execute each of its sub-pipelines to completion. So as long as each document was under a certain size threshold, memory usage could grow without bound. A fix for this was merged under &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40317&quot; title=&quot;$facet execution has no limit on how much memory it can consume&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40317&quot;&gt;&lt;del&gt;SERVER-40317&lt;/del&gt;&lt;/a&gt;, and backported all the way to 3.6.&lt;/p&gt;

&lt;p&gt;I&apos;m returning this to &quot;needs scheduling&quot; for discussion.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="721441">SERVER-40317</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="721441">SERVER-40317</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="269902" name="out3.png" size="385883" author="kevin.arhelger@mongodb.com" created="Tue, 14 Jul 2020 21:04:52 +0000"/>
                            <attachment id="269901" name="out3.svg" size="445678" author="kevin.arhelger@mongodb.com" created="Tue, 14 Jul 2020 21:04:52 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.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_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5002K00000npysBQAQ]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 15 Jul 2020 18:07:01 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 18 weeks, 1 day 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>ian.boros@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 18 weeks, 1 day 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>ian.boros@mongodb.com</customfieldvalue>
            <customfieldvalue>kevin.arhelger@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hxut93:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hua4p3:</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="3616">Query 2020-10-05</customfieldvalue>
    <customfieldvalue id="3617">Query 2020-10-19</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|hxufif:</customfieldvalue>

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