<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:41:37 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-35967] $sample with explain(true) hangs</title>
                <link>https://jira.mongodb.org/browse/SERVER-35967</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Observed in v3.6. Unable to reproduce on v3.4.&lt;/p&gt;

&lt;p&gt;$sample command &lt;em&gt;never returns&lt;/em&gt;&#160;when run with explain(true). db.currentOps() shows:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160;&quot;planSummary&quot;:&#160; &quot;MULTI_ITERATOR&quot;,&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160;&quot;numYields&quot;: 18619890,&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;numYields continuously increases.&lt;/p&gt;</description>
                <environment></environment>
        <key id="568185">SERVER-35967</key>
            <summary>$sample with explain(true) hangs</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="ian.boros@mongodb.com">Ian Boros</assignee>
                                    <reporter username="josef.ahmad@mongodb.com">Josef Ahmad</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 Jul 2018 16:18:48 +0000</created>
                <updated>Sun, 29 Oct 2023 22:30:08 +0000</updated>
                            <resolved>Mon, 30 Jul 2018 23:19:34 +0000</resolved>
                                    <version>3.6.0</version>
                                    <fixVersion>3.6.7</fixVersion>
                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="1960869" author="xgen-internal-githook" created="Mon, 30 Jul 2018 22:37:42 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ian Boros&apos;, &apos;email&apos;: &apos;ian.boros@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-35967&quot; title=&quot;$sample with explain(true) hangs&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-35967&quot;&gt;&lt;del&gt;SERVER-35967&lt;/del&gt;&lt;/a&gt; Ban explain() on $sample when storage engine supports random cursors&lt;br/&gt;
Branch: v3.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/9c3f90d24a36f07072a45dbc8c4694dbe1fc664b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/9c3f90d24a36f07072a45dbc8c4694dbe1fc664b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1939832" author="david.storch" created="Thu, 5 Jul 2018 19:02:09 +0000"  >&lt;p&gt;One more note: In the process of investigating this issue, I found a separate problem with explaining &lt;tt&gt;$sample&lt;/tt&gt; that affects 4.0 and master. See&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-35973&quot; title=&quot;Explain execution stats for $sample are not reported correctly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-35973&quot;&gt;&lt;del&gt;SERVER-35973&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="1939782" author="david.storch" created="Thu, 5 Jul 2018 18:31:57 +0000"  >&lt;p&gt;After investigating, I can confirm that this problem was introduced by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-19758&quot; title=&quot;Add &amp;quot;executionStats&amp;quot; and &amp;quot;allPlansExecution&amp;quot; explain modes to aggregation explain&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-19758&quot;&gt;&lt;del&gt;SERVER-19758&lt;/del&gt;&lt;/a&gt;, which added &quot;executionStats&quot; and &quot;allPlansExecution&quot; explain modes for aggregation explain. I can also confirm that it was fixed by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-29421&quot; title=&quot;Aggregation executionStats or allPlansExecution explain modes behave incorrectly with $limit&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-29421&quot;&gt;&lt;del&gt;SERVER-29421&lt;/del&gt;&lt;/a&gt;, meaning that this issue affects only the 3.6 branch. The problem occurs when the explain code attempts to run its underlying &lt;tt&gt;PlanExecutor&lt;/tt&gt; in order to gather execution statistics:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/6405d65b1d6432e138b44c13085d0c2fe235d6bd/src/mongo/db/pipeline/document_source_cursor.cpp#L190&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/6405d65b1d6432e138b44c13085d0c2fe235d6bd/src/mongo/db/pipeline/document_source_cursor.cpp#L190&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This &lt;tt&gt;PlanExecutor&lt;/tt&gt; encapsulates an execution plan which simply reads from a random cursor&#8212;a &lt;tt&gt;RecordCursor&lt;/tt&gt; obtained by calling &lt;a href=&quot;https://github.com/mongodb/mongo/blob/6405d65b1d6432e138b44c13085d0c2fe235d6bd/src/mongo/db/storage/record_store.h#L489-L502&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;RecordStore::getRandomCursor()&lt;/a&gt;. Existing random cursor implementations sample via a pseudorandom btree walk. They also never return EOF, but rather will sample infinitely (with replacement) as a caller iterates the cursor. The explain code is doing just this&#8212;in&#160;its attempt to gather stats from the cursor, it is stuck in an &lt;a href=&quot;https://github.com/mongodb/mongo/blob/6405d65b1d6432e138b44c13085d0c2fe235d6bd/src/mongo/db/query/plan_executor.cpp#L675-L677&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;infinite loop here&lt;/a&gt; checking for an EOF that will never come.&lt;/p&gt;

&lt;p&gt;The problem is that the explain code path iterates the underlying random cursor directly, circumventing the code in &lt;tt&gt;DocumentSourceSampleFromRandomCursor&lt;/tt&gt; which is responsible for duplicate elimination, and, importantly, for signaling EOF for &lt;tt&gt;$sample&lt;/tt&gt; queries. &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-29421&quot; title=&quot;Aggregation executionStats or allPlansExecution explain modes behave incorrectly with $limit&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-29421&quot;&gt;&lt;del&gt;SERVER-29421&lt;/del&gt;&lt;/a&gt; fixes the problem by changing our strategy for explain execution. Specifically, this fix consolidates the explain code path with the regular execution code path, such that exec stats are gathered by running the query in much the same way as the regular, non-explain code path.&lt;/p&gt;</comment>
                            <comment id="1939653" author="david.storch" created="Thu, 5 Jul 2018 17:17:57 +0000"  >&lt;p&gt;I can reproduce this issue on the 3.6 branch but not on the master branch. My initial guess is that this is a regression due to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-19758&quot; title=&quot;Add &amp;quot;executionStats&amp;quot; and &amp;quot;allPlansExecution&amp;quot; explain modes to aggregation explain&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-19758&quot;&gt;&lt;del&gt;SERVER-19758&lt;/del&gt;&lt;/a&gt; that was subsequently fixed by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-29421&quot; title=&quot;Aggregation executionStats or allPlansExecution explain modes behave incorrectly with $limit&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-29421&quot;&gt;&lt;del&gt;SERVER-29421&lt;/del&gt;&lt;/a&gt;. Assigning to myself to produce a more concrete root cause diagnosis.&lt;/p&gt;</comment>
                            <comment id="1939630" author="ramon.fernandez" created="Thu, 5 Jul 2018 16:58:51 +0000"  >&lt;p&gt;I can confirm this behavior: in 3.4.4 the &lt;tt&gt;explain()&lt;/tt&gt; command returns, in 3.6.5 doesn&apos;t.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="389305">SERVER-29421</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="568273">SERVER-35973</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="224125">SERVER-19758</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>5.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_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, 5 Jul 2018 16:58:51 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 28 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_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>
                            5 years, 28 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>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>ian.boros@mongodb.com</customfieldvalue>
            <customfieldvalue>josef.ahmad@mongodb.com</customfieldvalue>
            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu22hr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htst47:</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="2404">Query 2018-07-16</customfieldvalue>
    <customfieldvalue id="2405">Query 2018-07-30</customfieldvalue>
    <customfieldvalue id="2440">Query 2018-08-13</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;
&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;   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;db.c.drop()&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;for (i = 0; i &amp;lt; 1000; i++ ) { db.c.insertOne({size:1})}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;db.c.explain(true).aggregate({$sample: {size: 10}})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&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|hu1or3:</customfieldvalue>

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