<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:32:19 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-76295] Can TypedCommand parse request in owned manner?</title>
                <link>https://jira.mongodb.org/browse/SERVER-76295</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;When I use &lt;a href=&quot;https://github.com/10gen/mongo/blob/master/src/mongo/db/commands.h#L1207&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;TypedCommand&lt;/a&gt;, any BSONObjs in my request struct are not parsed in owned manner (e.g. &lt;a href=&quot;https://github.com/10gen/mongo-enterprise-modules/blob/8bc6022b5820c2bc93a995c10b50e54ca46c7baa/src/streams/commands/stream_ops.idl#L155&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;). This means that I cannot hold onto these objects after the command finishes running. I need to explicitly call `getOwned` on these objects to make them outlive command execution. While I can do this, this is brittle, I need to make sure to do this for all BSONObjs in all my request structs. It&apos;d be great if TypedCommand instead parsed the incoming BSONObjs in owned manner.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2318747">SERVER-76295</key>
            <summary>Can TypedCommand parse request in owned manner?</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="12300">Won&apos;t Do</resolution>
                                        <assignee username="backlog-server-servicearch">Backlog - Service Architecture</assignee>
                                    <reporter username="sandeep.dhoot@mongodb.com">Sandeep Dhoot</reporter>
                        <labels>
                    </labels>
                <created>Wed, 19 Apr 2023 15:59:36 +0000</created>
                <updated>Fri, 21 Apr 2023 03:14:25 +0000</updated>
                            <resolved>Fri, 21 Apr 2023 03:14:24 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="5364208" author="JIRAUSER1272673" created="Thu, 20 Apr 2023 22:36:25 +0000"  >&lt;p&gt;Cool, that does sound like a big change. Please feel free to close the issue. Thanks for looking into this!&lt;/p&gt;</comment>
                            <comment id="5363404" author="JIRAUSER1272673" created="Thu, 20 Apr 2023 17:58:40 +0000"  >&lt;p&gt;Sorry, I didn&apos;t fully get that. So if `request.body` is owned, any BSONObjs in the request body are also owned by this top level object and not individually owned at every level?&lt;/p&gt;

&lt;p&gt;Is there any other quick fix e.g. can TypedCommand let the derived class decide how to parse the request - owned or unowned?&lt;/p&gt;</comment>
                            <comment id="5360509" author="billy.donahue" created="Wed, 19 Apr 2023 20:38:51 +0000"  >&lt;p&gt;The request body isOwned. It owns its own SharedBuffer.&lt;br/&gt;
I didn&apos;t realize this and thought the enclosing Message owned the SharedBuffer.&lt;/p&gt;

&lt;p&gt;But the elements within the request are not self-owned. They&apos;re owned by that request body. They&apos;re all deferring all ownership concerns to the request body, which handles ownership so they don&apos;t have to.&lt;/p&gt;

&lt;p&gt;If the request contains an array of 100 objects, we are avoiding having to refcount the request&apos;s whole body 100 times.&lt;/p&gt;</comment>
                            <comment id="5360354" author="JIRAUSER1272673" created="Wed, 19 Apr 2023 19:44:31 +0000"  >&lt;p&gt;Thanks &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=billy.donahue%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;billy.donahue@mongodb.com&quot;&gt;billy.donahue@mongodb.com&lt;/a&gt; for the context, this makes sense.&lt;/p&gt;

&lt;p&gt;If this change could make things slower in the general case, then yeah, we don&apos;t need to make the change. I assumed that the `getOwned()` call in this case should be a no-op because probably the &lt;a href=&quot;https://github.com/10gen/mongo/blob/b62c27ea25a20843ce88d601843192350781fcbf/src/mongo/db/commands.h#L1264&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;opMsgRequest&lt;/a&gt; that TypedCommand uses is already an owned BSONObj. I assumed so because there is this `isOwned` assert &lt;a href=&quot;https://github.com/10gen/mongo/blob/b62c27ea25a20843ce88d601843192350781fcbf/src/mongo/db/commands/find_cmd.cpp#L227&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;. I am not able to tell why this OpMsgRequest instance is owned. If you know why, please share, I can then probably use the same trick in my code.&lt;/p&gt;</comment>
                            <comment id="5360292" author="billy.donahue" created="Wed, 19 Apr 2023 19:24:44 +0000"  >&lt;p&gt;If the &lt;tt&gt;TypedCommand&lt;/tt&gt; parsing generated a structure that participated in ownership, we&apos;d have slower parsing. The system we have today is optimized for the common case that the payload of a command is not retained by the server after the command ends.&lt;/p&gt;

&lt;p&gt;The call to &lt;tt&gt;getOwned&lt;/tt&gt; copies the &lt;tt&gt;BSONObj&lt;/tt&gt; out of the enclosing &lt;tt&gt;Message&lt;/tt&gt;. It is expensive and we can&apos;t do it by default because most commands won&apos;t benefit from owning the payload object. They only observe it.&lt;/p&gt;

&lt;p&gt;It sounds like your command has the uncommon requirement of retaining the object after the command is destroyed. I think that it&apos;s reasonable for your command to explicitly declare this. I don&apos;t think such declarations should appear in IDL yaml files, as it&apos;s purely a detail of the C++ implementation of the command, rather than something intrinsic to the payload type.&lt;/p&gt;

&lt;p&gt;I sympathize with the statement that this can be fragile. I think it&apos;s understood that BSONObj ownership is commonly considered too hard to reason about.&lt;/p&gt;

&lt;p&gt;I could imagine a useful utility function to detach an IDL-generated struct from its source &lt;tt&gt;Message&lt;/tt&gt; entirely via a deep copy. It could iterate through all &lt;tt&gt;BSONObj&lt;/tt&gt; data members and replace them with &lt;tt&gt;getOwned()&lt;/tt&gt; versions of themselves. But this wouldn&apos;t be super easy to write and might be too coarse anyway if the command only needs to retain some of the objects. This ideas is starting to get at a possibly generalized reflection API for IDL structs which would unlock other possibilities.&lt;/p&gt;</comment>
                    </comments>
                    <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_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25132"><![CDATA[Service Arch]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 19 Apr 2023 19:24:44 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        41 weeks, 6 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>billy.donahue@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            41 weeks, 6 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>backlog-server-servicearch</customfieldvalue>
            <customfieldvalue>billy.donahue@mongodb.com</customfieldvalue>
            <customfieldvalue>sandeep.dhoot@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i25emf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i1npxs:</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_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|i250rr:</customfieldvalue>

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