<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:46:02 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-37453] Delete PlanStage::dispose()</title>
                <link>https://jira.mongodb.org/browse/SERVER-37453</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Once all cursors are globally managed (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-37451&quot; title=&quot;Move all cursor ownership to the global cursor manager&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-37451&quot;&gt;&lt;del&gt;SERVER-37451&lt;/del&gt;&lt;/a&gt;) the dispose() mechanism for cleaning up &lt;tt&gt;ClientCursor&lt;/tt&gt; and &lt;tt&gt;PlanExecutor&lt;/tt&gt; will no longer be needed.&lt;/p&gt;</description>
                <environment></environment>
        <key id="613549">SERVER-37453</key>
            <summary>Delete PlanStage::dispose()</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="david.storch@mongodb.com">David Storch</assignee>
                                    <reporter username="david.storch@mongodb.com">David Storch</reporter>
                        <labels>
                            <label>todo_in_code</label>
                    </labels>
                <created>Wed, 3 Oct 2018 17:09:32 +0000</created>
                <updated>Sun, 29 Oct 2023 22:27:40 +0000</updated>
                            <resolved>Thu, 27 Aug 2020 13:19:28 +0000</resolved>
                                                    <fixVersion>4.7.0</fixVersion>
                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3361440" author="xgen-internal-githook" created="Thu, 27 Aug 2020 00:48:46 +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-37453&quot; title=&quot;Delete PlanStage::dispose()&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-37453&quot;&gt;&lt;del&gt;SERVER-37453&lt;/del&gt;&lt;/a&gt; Delete PlanStage::dispose()&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/6663d804ebf22ec5c4295d082ad3685bf801da6b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/6663d804ebf22ec5c4295d082ad3685bf801da6b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3358870" author="david.storch" created="Tue, 25 Aug 2020 19:31:59 +0000"  >&lt;p&gt;Although the above discussion about why &lt;tt&gt;dispose()&lt;/tt&gt; cannot be eliminated from the &lt;tt&gt;PlanExecutor&lt;/tt&gt; interface still holds, there is no longer any use for &lt;tt&gt;PlanStage::dispose()&lt;/tt&gt; due to the changes in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-48478&quot; title=&quot;Create a PlanExecutor implementation for executing a Pipeline&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-48478&quot;&gt;&lt;del&gt;SERVER-48478&lt;/del&gt;&lt;/a&gt;. I&apos;m repurposing this ticket to be specifically about deleting &lt;tt&gt;PlanStage::dispose()&lt;/tt&gt;.&lt;/p&gt;</comment>
                            <comment id="2519572" author="xgen-internal-githook" created="Wed, 6 Nov 2019 12:12:44 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;antkorsh&apos;, &apos;email&apos;: &apos;anton.korshunov@mongodb.com&apos;, &apos;name&apos;: &apos;Anton Korshunov&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-44203&quot; title=&quot;Complete TODO listed in SERVER-37453&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-44203&quot;&gt;&lt;del&gt;SERVER-44203&lt;/del&gt;&lt;/a&gt; Complete TODO listed in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-37453&quot; title=&quot;Delete PlanStage::dispose()&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-37453&quot;&gt;&lt;del&gt;SERVER-37453&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/e7828e2249c1d0b97ff981ce3d228648bdf02a52&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/e7828e2249c1d0b97ff981ce3d228648bdf02a52&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2146987" author="anton.korshunov" created="Wed, 13 Feb 2019 10:02:31 +0000"  >&lt;p&gt;The purpose of the dispose mechanism in the PlanExecutor/ClientCuror was to:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Ensure that a collection lock is acquired while detaching a PlanExecutor from the CursorManager.&lt;/li&gt;
	&lt;li&gt;Take responsibility to invoke dispose() methods before destruction of these objects, so that the caller doesn&apos;t need to care about it.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Since the dispose mechanism requires access to the current OperationContext and, before&#160;&quot;All cursors globally managed&quot; project, could acquire a lock to deregister its PlanExecutor, it wasn&apos;t feasible to implement the dispose mechanics through the means of a class destructor. Firstly, because acquiring a lock in destructor may fail and there is no a clean way to propagate this failure to the caller (as throwing an exception from a destructor is illegal and likely will result in abnormal program termination), and secondly, a destructor may not had access to the current OperationContext. The dispose mechanism solves these problems and also provides a mechanics to automatically call the dispose() method by utilizing the concept of unique_ptr deleters.&lt;/p&gt;

&lt;p&gt;In this work item we tried to get rid of the PlanExecutor::dispose() methods and its friends, driven by the idea that since the lock acquision doesn&apos;t come into play anymore with the introduction of the cursor manager scoped to the ServiceContext, rather than a collection, we may not need any longer the dispose mechanics. However, while implementing this change we came across a scenario where the dispose mechanism still stands out and proves to be an efficient (if not the only) way to deal with killCursors requests.&lt;/p&gt;

&lt;p&gt;Namely, DocumentSourceMergeCursors relies on the Pipeline::dispose() mechanism to thread the dispose call down as PlanExecutor -&amp;gt; PipelineProxy -&amp;gt; Pipeline -&amp;gt; DocumentSourceMergeCursors. If the dispose() is not called on DocumentSourceMergeCursors, the cursor may not get killed and we may end up with a situation when the async result merger invariant doesn&apos;t hold. This can be illustrated with the following test:&lt;/p&gt;

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

&lt;p&gt;Not properly performing the dispose step on DocumentSourceMergeCursors results in the invariant being violated in AsyncResultsMerger::~AsyncResultsMerger():&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;invariant(_remotesExhausted(lk) || _lifecycleState == kKillComplete)&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;So, for $mergeCursors we still need a valid OperationContext to attach to, and we need to ensure the dispose() methods gets called, so both the dispose() mechanism and a custom deleter would be hard to be replaced in this case.&lt;/p&gt;

&lt;p&gt;Another potential problem (although not so critical as with the DocumentSourceMergeCursors) is DocumentSourceFacet where we need to propage dispose() down to the source document. The following test would fail if this is not done properly:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/a66a5578d5b006cef85b16eac05c96b58c877ebe/src/mongo/db/pipeline/document_source_facet_test.cpp#L411&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/a66a5578d5b006cef85b16eac05c96b58c877ebe/src/mongo/db/pipeline/document_source_facet_test.cpp#L411&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;   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;facetStage-&amp;gt;dispose();&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;ASSERT_TRUE(mockSource-&amp;gt;isDisposed);&#160; &#160;&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;In light of the above, it was decided to keep the dispose mechanism unchanged as it&apos;s still useful in certain cases and would be hard to be replaced with some other approach. &#160; &#160;&lt;/p&gt;</comment>
                            <comment id="2140200" author="david.storch" created="Wed, 6 Feb 2019 19:23:35 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=anton.korshunov&quot; class=&quot;user-hover&quot; rel=&quot;anton.korshunov&quot;&gt;anton.korshunov&lt;/a&gt;, since this is closely related to work I&apos;ve been doing for the &quot;all cursors globally managed&quot; project, please add me to any code review you produce. Thanks! Also, I&apos;m happy to help if you have any questions or run into any issues.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="563250">SERVER-35769</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="684688">SERVER-39392</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="935555">SERVER-43448</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="978495">SERVER-44203</issuekey>
        </issuelink>
                            </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_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, 13 Feb 2019 10:02:31 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 24 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 24 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>anton.korshunov@mongodb.com</customfieldvalue>
            <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|hu9flj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr8hxj:</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="2788">Query 2019-02-25</customfieldvalue>
    <customfieldvalue id="3614">Query 2020-09-07</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|hu91uv:</customfieldvalue>

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