<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:42:10 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-79891] Inconsistent profiling output for inserts</title>
                <link>https://jira.mongodb.org/browse/SERVER-79891</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;For the insert operation, the profiling output is currently inconsistent in some ways:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;1) Inconsistency between inserts initiates from mongod v.s. inserts sent from mongos&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;When we do an insert directly from monogd, the profile entry in the &amp;lt;db&amp;gt;.system.profile collection will contain and entry with a field &quot;command&quot; like this:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;&#160; &#160; &quot;command&quot; : {&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; &quot;insert&quot; : &quot;coll&quot;,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; &quot;lsid&quot; : { ... },&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; &quot;$clusterTime&quot; : { ... },&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160; &#160; &quot;$db&quot; : &quot;test&quot;,&lt;/tt&gt;&lt;/p&gt;

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

&lt;p&gt;Note that this does not include the actual documents inserted (which seems not desired), however if the insert command is sent from mongos, &quot;command&quot; field will include a subField &quot;documents&quot; that is an array of all the inserted documents. Additionally the missing &quot;documents&quot; subField is also a problem for &apos;slow query&apos; logs as it prints the command using the same way described below.&lt;/p&gt;

&lt;p&gt;The reason of the difference is two-folded:&lt;/p&gt;

&lt;p&gt;a) For the similar reason described in&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-79442&quot; title=&quot;Update command may send mirrored reads without filter, hint or collation&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-79442&quot;&gt;SERVER-79442&lt;/a&gt;, for requests initiated from mongod, any field that are marked as &apos;supports_doc_sequence&apos; (such as the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/ops/write_ops.idl#L389&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;documents&quot;&lt;/a&gt; field in the insert command, the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/ops/write_ops.idl#L413&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;updates&quot;&lt;/a&gt; field in the update command and the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/ops/write_ops.idl#L450&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;deletes&quot;&lt;/a&gt; field in the delete command) will only be present in the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/rpc/op_msg.h#L178&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;OpMsg::sequences&lt;/a&gt; vector, but not in &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/rpc/op_msg.h#L177&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;OpMsg::body&lt;/a&gt;, while for requests sent from mongos, requests are serialized in a way such that all fields are in &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/rpc/op_msg.h#L177&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;OpMsg::body&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;b) For every command handled by mongod, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/service_entry_point_common.cpp#L2098&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;curOpCommandSetup()&lt;/a&gt; will first be called to set basic command info in &lt;tt&gt;CurOp&lt;/tt&gt;,&#160; where it calls &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/service_entry_point_common.cpp#L2108&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;setOpDescription_inlock()&lt;/a&gt; to set opDescription using &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/rpc/op_msg.h#L177&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;OpMsg::body&lt;/a&gt;, and this is basically what&apos;s printed in the &quot;command&quot; field of the profile entry. However, the problem is that unlike update and delete command where they unroll each update/delete op and &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/ops/write_ops_exec.cpp#L1341&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;overwrite the opDescription&lt;/a&gt; with the individual update/delete op, insert &lt;a href=&quot;https://github.com/mongodb/mongo/blob/fd837c1c905798c96fdd862a50388f89774a52d7/src/mongo/db/ops/write_ops_exec.cpp#L1040-L1042&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;does not do that&lt;/a&gt;. Combined with a), inserts initiated from mongod will lose the &quot;documents&quot; field in the profile entry.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;2)&lt;/b&gt;&#160;&lt;b&gt;Inconsistency between inserts v.s. updates/deletes&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;From the above example profile output, we can see that insert command includes some request-level fields like &lt;tt&gt;$clusterTime&lt;/tt&gt;, &lt;tt&gt;$db&lt;/tt&gt;, &lt;tt&gt;txnNumber&lt;/tt&gt;, etc. However due to aforementioned reason b), update and delete commands will overwrite the opDescription with individual update/delete op and so will not include those request-level fields. And we seem to be relying on this to for JS tests because when I did a &lt;a href=&quot;https://evergreen.mongodb.com/filediff/64d1f3aba4cf47be22b54112/?file_name=src%2Fmongo%2Fdb%2Fops%2Fwrite_ops_exec.cpp&amp;amp;patch_number=0&amp;amp;commit_number=0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;one-line change&lt;/a&gt; to make inserts also overwrite opDescription with the inserted documents, I saw a bunch of &lt;a href=&quot;https://spruce.mongodb.com/version/64d1f3aba4cf47be22b54112&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;tests failed&lt;/a&gt; because they expect the request level fields being present in the insert command profile output. I think ultimately insert/update/delete should have consistent profile entry format, but I&apos;m not sure whether we want to fix insert or fix update/delete. If I have to guess, we probably want to have the request-level fields to be present in update/delete as well.&lt;/p&gt;

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

&lt;p&gt;(Just to add on a bit, currently an update/delete command creates nested CurOp and so would call &lt;a href=&quot;https://github.com/mongodb/mongo/blob/bbe64d5fd2d41b8cb439afc9756c87091e576bb0/src/mongo/db/service_entry_point_common.cpp#L2439-L2470&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CurOp::completeAndLogOperation() and profile() for the parent CurOp&lt;/a&gt;, in addition to the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/bbe64d5fd2d41b8cb439afc9756c87091e576bb0/src/mongo/db/ops/write_ops_exec.cpp#L317-L330&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;calls for each individual update/delete entry&lt;/a&gt;. Usually the result is correct, but under certain profile/logging configurations, the profile output and/or slow query logs might be slightly weird, and this is a bit confusing to developer even when the result is correct which feels like a tech debt.)&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2413796">SERVER-79891</key>
            <summary>Inconsistent profiling output for inserts</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="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="backlog-query-execution">Backlog - Query Execution</assignee>
                                    <reporter username="wenbin.zhu@mongodb.com">Wenbin Zhu</reporter>
                        <labels>
                    </labels>
                <created>Thu, 10 Aug 2023 01:28:40 +0000</created>
                <updated>Fri, 17 Nov 2023 20:47:27 +0000</updated>
                                                                                                <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="5642198" author="JIRAUSER1258790" created="Fri, 18 Aug 2023 05:39:54 +0000"  >&lt;p&gt;Note: findAndModify seems to have the same inconsistency problem mentioned in 2).&lt;/p&gt;</comment>
                            <comment id="5626632" author="JIRAUSER1258790" created="Thu, 10 Aug 2023 16:36:51 +0000"  >&lt;p&gt;We&apos;re working on &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-78258&quot; title=&quot;Implement profiling for bulkWrite command&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-78258&quot;&gt;&lt;del&gt;SERVER-78258&lt;/del&gt;&lt;/a&gt; and we initially hoped to have bulkWrite profiling output to be identical to normal writes, but due to this issue it&apos;s not quite doable at this time. However we think it&apos;s okay to be slightly different so we not blocked for now.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="2413797">SERVER-79892</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>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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 10 Aug 2023 15:47:12 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        24 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>chris.hutchinson@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            24 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-query-execution</customfieldvalue>
            <customfieldvalue>wenbin.zhu@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i2lofb:</customfieldvalue>

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

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