<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:17:05 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-8312] return value &quot;n&quot; in db.getLastErrorCmd()  have BUG</title>
                <link>https://jira.mongodb.org/browse/SERVER-8312</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;After updating and unsetting a field, we get result by db.getLastErrorCmd().&lt;br/&gt;
we found strange `n&apos; value returned.&lt;br/&gt;
see below:&lt;/p&gt;</description>
                <environment>FreeBSD 7.3-RELEASE FreeBSD 7.3-RELEASE root@:/usr/src/sys/amd64/compile/GENERIC  amd64&lt;br/&gt;
db version v2.2.0, pdfile version 4.5&lt;br/&gt;
</environment>
        <key id="63103">SERVER-8312</key>
            <summary>return value &quot;n&quot; in db.getLastErrorCmd()  have BUG</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="9">Done</resolution>
                                        <assignee username="jantje.daniel">Ian Daniel</assignee>
                                    <reporter username="ijerryrat">HongYing</reporter>
                        <labels>
                    </labels>
                <created>Thu, 24 Jan 2013 04:21:55 +0000</created>
                <updated>Mon, 11 Jul 2016 17:58:52 +0000</updated>
                            <resolved>Mon, 18 Feb 2013 03:36:58 +0000</resolved>
                                    <version>2.2.0</version>
                                                    <component>Querying</component>
                    <component>Write Ops</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="257357" author="jantje.daniel" created="Mon, 4 Feb 2013 02:13:40 +0000"  >&lt;p&gt;Hi HongYing,&lt;/p&gt;

&lt;p&gt;It looks like you might be running these commands interactively in the shell. db.getLastError() is unreliable in the shell. A carriage return in the shell results in GetLastError being run. This then produced unreliable results when you call it again. &lt;/p&gt;

&lt;p&gt;There are several possible solutions:&lt;/p&gt;

&lt;p&gt;1. Write up your commands into a file with a .js suffix, and pass it to mongo at the command line.&lt;/p&gt;

&lt;p&gt;2. If running interactively, put the db.getLastErrorCmd() on the same line as the update (separated by a semi-colon). That is:&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.bobo.update({a:1, b:2}, {$unset:{c:1, d:1}}); db.getLastErrorCmd()&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;3. If you want to run it on a separate line, instead use the db.getPrevError() command.&lt;/p&gt;

&lt;p&gt;4. Set verbose to true in the shell (set verbose true). This will then tell you how many objects were updated.&lt;/p&gt;

&lt;p&gt;If none of these actually fixes the problem, are you sharding? I ask because in the just released 2.2.3 we fixed several bugs in which a mongos returns an incorrect GetLastError. You should try in 2.2.3 to see if this resolves the problem.&lt;/p&gt;

&lt;p&gt;Kind regards,&lt;br/&gt;
Ian&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>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 4 Feb 2013 02:13:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 2 weeks, 3 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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 2 weeks, 3 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10024"><![CDATA[FreeBSD]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>ijerryrat</customfieldvalue>
            <customfieldvalue>jantje.daniel</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrn9yv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrls6f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>40621</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_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;&amp;gt; db.bobo.save(&lt;/p&gt;
{a:1, b:2, c:3, d:4}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.bobo.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;5100b05af1c2c68819360d1a&quot;), &quot;a&quot; : 1, &quot;b&quot; : 2, &quot;c&quot; : 3, &quot;d&quot; : 4 }
&lt;p&gt;&amp;gt; db.bobo.update(&lt;/p&gt;
{a:1, b:2}
&lt;p&gt;, {$unset:{c:1, d:1}})&lt;br/&gt;
&amp;gt; db.getLastErrorCmd()&lt;br/&gt;
{&lt;br/&gt;
        &quot;n&quot; : 0,                    // &amp;lt;------- it expected to be `1`&lt;br/&gt;
        &quot;lastOp&quot; : &lt;/p&gt;
{
                &quot;t&quot; : 1358999706000,
                &quot;i&quot; : 1
        }
&lt;p&gt;,&lt;br/&gt;
        &quot;connectionId&quot; : 131,&lt;br/&gt;
        &quot;err&quot; : null,&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;br/&gt;
&amp;gt; db.bobo.find(&lt;/p&gt;
{a:1, b:2}
&lt;p&gt;)&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;5100b05af1c2c68819360d1a&quot;), &quot;a&quot; : 1, &quot;b&quot; : 2 }
&lt;p&gt;&amp;gt; db.bobo.update(&lt;/p&gt;
{a:1}
&lt;p&gt;, {$unset:{b:1}})&lt;br/&gt;
&amp;gt; db.getLastErrorCmd()&lt;br/&gt;
{&lt;br/&gt;
        &quot;updatedExisting&quot; : true,&lt;br/&gt;
        &quot;n&quot; : 1,&lt;br/&gt;
        &quot;lastOp&quot; : &lt;/p&gt;
{
                &quot;t&quot; : 1358999741000,
                &quot;i&quot; : 2
        }
&lt;p&gt;,&lt;br/&gt;
        &quot;connectionId&quot; : 131,&lt;br/&gt;
        &quot;err&quot; : null,&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|ht0mmv:</customfieldvalue>

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