<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:29:12 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-32103] CTRL-C in mongo shell does not terminate long running ops if connected to mongos</title>
                <link>https://jira.mongodb.org/browse/SERVER-32103</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/shell/shell_utils.cpp#L298&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;killOperationsOnAllConnections&lt;/a&gt; is called in response to CTRL-C in the mongo shell. It finds long-running operations started by this shell and provides the user the option to terminate them. This is accomplished with the &lt;tt&gt;currentOp&lt;/tt&gt; and &lt;tt&gt;killOp&lt;/tt&gt; commands.&lt;/p&gt;

&lt;p&gt;For each connection, the shell calls &lt;tt&gt;currentOp&lt;/tt&gt; and examines &lt;tt&gt;client&lt;/tt&gt; or &lt;tt&gt;client_s&lt;/tt&gt; to determine if that command was started by the current shell. When a command is run against a mongod, &lt;tt&gt;client&lt;/tt&gt; contains the IP:PORT of the mongo shell. These commands prompt for termination. If however the command is routed through a mongos, &lt;tt&gt;client_s&lt;/tt&gt; contains the IP:PORT of the &lt;b&gt;mongos&lt;/b&gt;, not the mongo shell. These commands do not prompt for termination and are left running on the mongod.&lt;/p&gt;</description>
                <environment></environment>
        <key id="464771">SERVER-32103</key>
            <summary>CTRL-C in mongo shell does not terminate long running ops if connected to mongos</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="james.kovacs@mongodb.com">James Kovacs</reporter>
                        <labels>
                            <label>neweng</label>
                            <label>query-44-grooming</label>
                    </labels>
                <created>Tue, 28 Nov 2017 17:24:47 +0000</created>
                <updated>Tue, 6 Dec 2022 03:45:50 +0000</updated>
                                            <version>3.4.10</version>
                                                    <component>Shell</component>
                                        <votes>0</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="2305299" author="david.storch" created="Fri, 28 Jun 2019 19:42:17 +0000"  >&lt;p&gt;Flagging for re-triage. We may be able to pursue a simpler fix to this now. &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ian.boros&quot; class=&quot;user-hover&quot; rel=&quot;ian.boros&quot;&gt;ian.boros&lt;/a&gt;&apos;s prototype for a fix involved creating a new &lt;tt&gt;DBCommandCursor&lt;/tt&gt; concept, but this may now be supported by the pre-existing &lt;tt&gt;DBClientCursor&lt;/tt&gt; class.&lt;/p&gt;</comment>
                            <comment id="1800118" author="charlie.swanson" created="Thu, 8 Feb 2018 22:05:35 +0000"  >&lt;p&gt;Ok - so I think I&apos;ve figured out what&apos;s going on here.&lt;/p&gt;

&lt;p&gt;It looks like the shell is trying to identify which operations in the currentOp output were started by itself (this particular instance of the shell). It wants to do this to avoid killing &lt;em&gt;all&lt;/em&gt; operations on the server, instead killing only its own.&lt;/p&gt;

&lt;p&gt;To do this, it&apos;s looking at either the &apos;client&apos; or &apos;client_s&apos; field in the currentOp output. The &lt;a href=&quot;https://docs.mongodb.com/manual/reference/command/currentOp/#currentOp.client&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&apos;client&apos; field&lt;/a&gt; usually identifies who started the operation (it&apos;s something like &quot;127.0.0.1:53518&quot;, from what I can tell this is the host and port that the request came from). When the shell is talking to a mongod, this will be the shell&apos;s own URI because the request was sent directly from the shell to the mongod. Thus when connected to a mongod, the shell will be able to correctly kill its own operations.&lt;/p&gt;

&lt;p&gt;When currentOp is run against mongos, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/29948ab155070f197fe4e6c635e689ce122d82ca/src/mongo/db/pipeline/document_source_current_op.cpp#L123-L124&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the &apos;client&apos; field is renamed to be &apos;client_s&apos;&lt;/a&gt;, to make it clear that this is describing which &lt;em&gt;mongos&lt;/em&gt; the operation originated from. The shell uses this field to try to figure out if the request came from itself, but it will never match. The shell never connects directly to the mongod which generates this information, so the &quot;client_s&quot; field will always be the host and port corresponding to the mongos&apos; request.&lt;/p&gt;

&lt;p&gt;So, the shell never finds any operations in progress that it started, and never prompts the user to interrupt them. It looks like interrupting operations from a shell connected to a mongos has just never worked (I tested on 3.2, 3.4 and 3.6 - it just crashed on 3.2 (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-23168&quot; title=&quot;Shell killOperationsOnAllConnections doesn&amp;#39;t handle currentOp failure&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-23168&quot;&gt;&lt;del&gt;SERVER-23168&lt;/del&gt;&lt;/a&gt;), and never prompted on 3.4 and 3.6).&lt;/p&gt;

&lt;p&gt;I see two options going forward:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;We can fix this by instead relying on the client metadata to identify our own operations. The shell generates the client metadata object, including a &apos;clientMetadata.mongos.client&apos; field which has the host and port we&apos;re looking for. It seems safe to assume that the server will never modify the client metadata, and will always report it back the way we sent it. We could use this information to identify our own operations. This strategy would likely be eligible for backport to 3.6 at least (3.4 looks like it doesn&apos;t include as much client metadata information in currentOp, so it might not work there).&lt;/li&gt;
	&lt;li&gt;We can wait until we implement &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-18094&quot; title=&quot;currentOp on a mongoS should also show current mongoS operations&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-18094&quot;&gt;&lt;del&gt;SERVER-18094&lt;/del&gt;&lt;/a&gt;, in which case the (mongos-local) currentOp entry will likely (hopefully) include the shell&apos;s desired information.&lt;/li&gt;
&lt;/ol&gt;

</comment>
                            <comment id="1772788" author="ian@10gen.com" created="Fri, 12 Jan 2018 15:38:43 +0000"  >&lt;p&gt;Assigning to Charlie for future sprint to at least investigate complexity so we can/should decide whether to work into this project.&lt;/p&gt;</comment>
                            <comment id="1766224" author="greg.mckeon" created="Fri, 5 Jan 2018 16:36:40 +0000"  >&lt;p&gt;Sending to Query team to see if this can be done as part of the sharded kill epic.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="515447">SERVER-34077</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="12487">SERVER-1445</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="272847">SERVER-23168</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="198454">SERVER-18094</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="371535">SERVER-28649</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>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.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_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[500A000000Z4Cv6IAF]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 5 Jan 2018 16:36:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 32 weeks, 5 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>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 32 weeks, 5 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>charlie.swanson@mongodb.com</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>greg.mckeon@mongodb.com</customfieldvalue>
            <customfieldvalue>ian@mongodb.com</customfieldvalue>
            <customfieldvalue>james.kovacs@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htl0fz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2gvb:</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="2122">Query 2018-03-26</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;ol&gt;
	&lt;li&gt;Create a sharded cluster (e.g. &lt;tt&gt;mlaunch init --sharded 1 --single --port 47017&lt;/tt&gt;)&lt;/li&gt;
	&lt;li&gt;Connect to the mongos using the mongo shell: &lt;tt&gt;mongo --port 47017&lt;/tt&gt;&lt;/li&gt;
	&lt;li&gt;Start a long-running operation:
&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;use test&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;db.foo.remove({})&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;db.foo.insert({})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.foo.find({$where: &quot;for(var i=0;i&amp;lt;100000;i++) sleep(1000)&quot;})&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;/li&gt;
	&lt;li&gt;Launch a second mongo shell &lt;tt&gt;mongo --port 47017&lt;/tt&gt; and execute &lt;tt&gt;db.currentOp()&lt;/tt&gt;. Notice the long-running operation started in the previous step.&lt;/li&gt;
	&lt;li&gt;In the first shell, press CTRL-C. Notice that you are not prompted to terminate the operation.&lt;/li&gt;
	&lt;li&gt;In the second shell, run &lt;tt&gt;db.currentOp()&lt;/tt&gt;. Notice that the long-running operation is still executing.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;If you repeat the above steps connected to the mongod directly instead, you are prompted to terminate the long-running command as expected.&lt;/p&gt;</customfieldvalue>

                        </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|htkmjr:</customfieldvalue>

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