<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:00:46 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>[DOCS-10527] Docs for SERVER-19318: currentOp command should return cursor</title>
                <link>https://jira.mongodb.org/browse/DOCS-10527</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;h1&gt;&lt;a name=&quot;DocumentationRequestSummary%3A&quot;&gt;&lt;/a&gt;Documentation Request Summary: &lt;/h1&gt;

&lt;p&gt;This series of changes adds two new features and reimplements a third:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Adds a new aggregation stage, $currentOp, which produces a stream of documents describing active or dormant operations on the server as input for the rest of the pipeline. These documents are of the same format as the older currentOp command.&lt;/li&gt;
	&lt;li&gt;Adds a new shell helper, db.aggregate, which works similarly to db.&amp;lt;collection&amp;gt;.aggregate but produces an aggregation at the database level, of the form 
{ aggregate: 1 }&lt;/li&gt;
	&lt;li&gt;Reimplements the currentOp command as a $currentOp aggregation.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The primary distinction between $currentOp and the previous currentOp command is that the latter operated by consolidating all results into a single document before returning it to the user. On busy systems, particularly sharded clusters, this meant that the document would frequently grow beyond the 16MB BSON limit and result in an exception. To combat this, we were forced to limit the size of each document to a maximum of 1000 bytes, converting the BSON representation of the operation to a string if it exceeded this threshold; this often made processing currentOp output cumbersome and unpredictable for the user. Because it is part of the aggregation pipeline and produces a cursor from which documents are streamed, $currentOp is neither subject to the BSON limit nor does it need to truncate operations for space. In addition, $currentOp allows the user to easily perform any arbitrary transformation of the results as they traverse the pipeline.&lt;/p&gt;

&lt;p&gt;The new $currentOp stage adheres to the same syntactic form as existing aggregation stages. It is defined and appears in the pipeline as follows:&lt;/p&gt;

&lt;p&gt;{ $currentOp: &lt;/p&gt;
{ &amp;lt;param&amp;gt;: &amp;lt;value&amp;gt; }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;$currentOp takes three optional boolean parameters, all of which default to &apos;false&apos;:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;allUsers. If false, $currentOp will report only those operations belonging to the user who ran $currentOp. If true, $currentOp will report operations belonging to all users. The &quot;inprog&quot; privilege is necessary to run $currentOp with allUsers:true on a mongod. No special privileges are required to run allUsers:false on mongod; an authenticated user always has the right to view their own ops. When running $currentOp on a cluster via mongos, the inprog privilege is always required regardless of the allUsers parameter.&lt;/li&gt;
	&lt;li&gt;idleConnections. If false, $currentOp will only report active operations; if false, all operations including idle connections and system threads will be returned.&lt;/li&gt;
	&lt;li&gt;truncateOps. At present, this is considered an internal parameter and may not need to be documented publicly, but might prove useful for some users. If true, truncateOps will cause the to revert to the old behaviour of limiting the size of operations in each document to 1000 bytes, and converting them to a string summary if they exceed this limit.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;There are a number of constraints:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;$currentOp must be the first stage in the pipeline.&lt;/li&gt;
	&lt;li&gt;A $currentOp pipeline can only be run on the admin database&lt;/li&gt;
	&lt;li&gt;The &quot;aggregate&quot; namespace parameter must be set to 1.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Any failure to adhere to the above will result in an exception. A typical invocation of the &quot;aggregate&quot; command with $currentOp appears as follows:&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;db.adminCommand( { aggregate: 1, pipeline: [ { $currentOp: { allUsers: true, idleConnections: true } }, { $match: { shard: &quot;shard01&quot; } } ], cursor: {} } )&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;The currentOp command itself has been reimplemented to use $currentOp to generate its results. Importantly, &lt;b&gt;it still retains the previous behaviour&lt;/b&gt; of returning all results in a single document and truncating operations by default. This was done in order to retain the existing API while giving users the option of moving to $currentOp aggregations if they wish to avail of its advantages. Three changes to the behaviour of the currentOp command have been made:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;The currentOp command no longer reports the raw command responses from each shard in a cluster as well as the &quot;inprog&quot; array of operations. It will now only return the &quot;inprog&quot; array.&lt;/li&gt;
	&lt;li&gt;The currentOp command will now fail if any of the shards cannot be contacted. This is a slight change from previously, where the command would report failure but also include the raw results of any shards which DID respond.&lt;/li&gt;
	&lt;li&gt;The hostname of the machine on which the aggregation ran has been added as a new field in the $currentOp output. On a sharded cluster, it will additionally report the name of the shard.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Finally, a new helper has been added to the mongo shell to facilitate $currentOp aggregations. It takes two arguments: an array of hashes defining the aggregation pipeline, and a hash of options:&lt;/p&gt;

&lt;p&gt;db.aggregate(&lt;span class=&quot;error&quot;&gt;&amp;#91;{$currentOp:{}}, {$match:{...}} ... &amp;#93;&lt;/span&gt;, &lt;/p&gt;
{ option: value, ... }
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;This is equivalent to running a command of the following form:&lt;/p&gt;

&lt;p&gt;db.runCommand({ aggregate: 1, pipeline: &lt;span class=&quot;error&quot;&gt;&amp;#91;{$currentOp:{}}, {$match:{...}} ... &amp;#93;&lt;/span&gt;, option: value, ... , cursor: {} })&lt;/p&gt;

&lt;p&gt;The format and available options are identical to those provided by the db.&amp;lt;collection&amp;gt;.aggregate helper and the aggregation framework. For now, running db.aggregate with any stages other than $currentOp or on any database other than admin will produce an exception, but it may be put to further use in the future.&lt;/p&gt;

&lt;p&gt;Please feel free to ping me on Slack if there&apos;s anything you&apos;d like clarified!&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Bernard&lt;/p&gt;

&lt;h1&gt;&lt;a name=&quot;EngineeringTicketDescription%3A&quot;&gt;&lt;/a&gt;Engineering Ticket Description:&lt;/h1&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;mongos&amp;gt; db.currentOp(true)&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;2015-07-07T11:26:00.759-0700 error: {&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;	&quot;$err&quot; : &quot;BufBuilder attempted to grow() to 134217728 bytes, past the 64MB limit.&quot;,&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;	&quot;code&quot; : 13548&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;} at src/mongo/shell/query.js:131&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;There are 225 connections to the mongos, with 40 shards, each &lt;br/&gt;
with a 5-member replica set. lsof shows ~4600 open connections to the mongos process.&lt;/p&gt;

&lt;p&gt;Trying to grow a buffer to 134 MB for the output of 4600 connections seems a little large (~32 kB/connection entry), but making the command scale is the goal.&lt;/p&gt;

&lt;p&gt;Introducing a cursor to the command (and others like it) would allow it to work on arbitrarily sized clusters.&lt;/p&gt;</description>
                <environment></environment>
        <key id="403641">DOCS-10527</key>
            <summary>Docs for SERVER-19318: currentOp command should return cursor</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="pavithra.vetriselvan@mongodb.com">Pavithra Vetriselvan</assignee>
                                    <reporter username="emily.hall">Emily Hall</reporter>
                        <labels>
                            <label>aggregation</label>
                    </labels>
                <created>Thu, 13 Jul 2017 15:56:30 +0000</created>
                <updated>Sun, 29 Oct 2023 13:59:27 +0000</updated>
                            <resolved>Tue, 17 Oct 2017 22:13:31 +0000</resolved>
                                                    <fixVersion>3.5.10</fixVersion>
                                    <component>Server</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1699685" author="xgen-internal-githook" created="Mon, 16 Oct 2017 14:38:54 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;pavi@MacBook-Pro-77.local&apos;, &apos;name&apos;: &apos;Pavithra Vetriselvan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-10527&quot; title=&quot;Docs for SERVER-19318: currentOp command should return cursor&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-10527&quot;&gt;&lt;del&gt;DOCS-10527&lt;/del&gt;&lt;/a&gt; switched currentOp from operators to stages section&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/4273da1dc4df60de6983edb541cd969b89700b7d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/4273da1dc4df60de6983edb541cd969b89700b7d&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1696836" author="xgen-internal-githook" created="Thu, 12 Oct 2017 04:07:50 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;pavi@MacBook-Pro-77.local&apos;, &apos;name&apos;: &apos;Pavithra Vetriselvan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-10527&quot; title=&quot;Docs for SERVER-19318: currentOp command should return cursor&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-10527&quot;&gt;&lt;del&gt;DOCS-10527&lt;/del&gt;&lt;/a&gt; added new currentOp and db.aggregate() pages&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/c621830a63fde1ab813bbd3c91a1a232000bbc2c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/c621830a63fde1ab813bbd3c91a1a232000bbc2c&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                            <outwardlinks description="documents">
                                        <issuelink>
            <issuekey id="215366">SERVER-19318</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>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 19 Sep 2017 15:52:09 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        6 years, 17 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>DOCS-10575</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>
                            6 years, 17 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>emily.hall</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>pavithra.vetriselvan@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htaujb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|ht2quv:</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_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htaglz:</customfieldvalue>

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