<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:36:33 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-14972] Cursor count incorrectly reports non-zero value</title>
                <link>https://jira.mongodb.org/browse/SERVER-14972</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;(I&apos;m marking this minor due to the ancientness of the release not severity of the issue.)&lt;/p&gt;

&lt;p&gt;We created a new index and suddenly queries using that index were reporting non-zero counts when they had zero elements in their resultset. I&apos;ve put the console output in the attachment which shows &lt;tt&gt;cursor.count()&lt;/tt&gt; returning non-zero but attempts to access element 0 generating an error and then shows the explain which clearly shows that `n` is 0.&lt;/p&gt;

&lt;p&gt;The index we created was&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;ensureIndex({&apos;_id.tag&apos;: 1, &apos;_id.org&apos;: 1, &apos;_id.course&apos;: 1, &apos;definition.children&apos;: 1})&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;When we deleted the index, the code worked once again.&lt;/p&gt;

&lt;p&gt;This is for the open sourced edx.org code base (feel free to look at the code &lt;a href=&quot;https://github.com/edx/edx-platform/blob/master/common/lib/xmodule/xmodule/modulestore/mongo/base.py#L1199&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;base.py _get_raw_parent_location&lt;/a&gt;)&lt;/p&gt;</description>
                <environment>mongodb-2.2, pymongo 2.4, </environment>
        <key id="151782">SERVER-14972</key>
            <summary>Cursor count incorrectly reports non-zero value</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="4">Incomplete</resolution>
                                        <assignee username="sam.kleinman">Sam Kleinman</assignee>
                                    <reporter username="dmitchell@edx.org">Don Mitchell</reporter>
                        <labels>
                    </labels>
                <created>Mon, 11 Aug 2014 13:59:00 +0000</created>
                <updated>Sat, 16 May 2015 02:20:36 +0000</updated>
                            <resolved>Sat, 16 May 2015 02:20:36 +0000</resolved>
                                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="900959" author="samk" created="Wed, 29 Apr 2015 15:04:12 +0000"  >&lt;p&gt;Sorry for the delay here, I hope we can get to the bottom of this &lt;/p&gt;

&lt;p&gt;There have been some substantial changes to indexes since the 2.2 series (which is EOL,) and there were some improvements to the changes in the 2.4 series that seem related to your case. &lt;/p&gt;

&lt;p&gt;Most importantly, earlier versions (before 2.6) of MongoDB did not strictly enforce the &lt;a href=&quot;http://docs.mongodb.org/manual/reference/limits/#Index-Key-Limit&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;1024 byte index key length restriction&lt;/a&gt;, which lead to indexes that omitted documents with longer keys. (e.g. &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10749&quot; title=&quot;Query results differ depending on the utilized index&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10749&quot;&gt;&lt;del&gt;SERVER-10749&lt;/del&gt;&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-3372&quot; title=&quot;Allow indexing fields of arbitrary length&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-3372&quot;&gt;&lt;del&gt;SERVER-3372&lt;/del&gt;&lt;/a&gt;) If the indexed fields don&apos;t exist in all the documents you&apos;re counting, this would easily explained the observed behavior. This effect is part of the issue addressed in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10435&quot; title=&quot;Compound index on hashmap field results in inconsistent count&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10435&quot;&gt;&lt;del&gt;SERVER-10435&lt;/del&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Otherwise, you may be observing &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-4529&quot; title=&quot;fast count mode should not be used when matching against null&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-4529&quot;&gt;&lt;del&gt;SERVER-4529&lt;/del&gt;&lt;/a&gt; if some indexed fields don&apos;t exist in all documents. The correctness issues with count operations were fixed in 2.4 and better indexed field length validation was added in 2.6. &lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Do you have plans to upgrade to a more recent version of MongoDB?&lt;/li&gt;
	&lt;li&gt;Just to verify when you say &quot;we deleted the index, the code worked again,&quot; mean that the count reported zero (correctly) or the query returned results?&lt;/li&gt;
	&lt;li&gt;Do you have a way to validate your code and data against a 2.6 or a 3.0 release of MongoDB?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Cheers,&lt;br/&gt;
sam&lt;/p&gt;</comment>
                            <comment id="696907" author="dmitchell@edx.org" created="Wed, 20 Aug 2014 15:35:54 +0000"  >&lt;p&gt;No, we should shard it, but we haven&apos;t. (and yes, when I noticed this ticket was on doc I wondered how and why it was but didn&apos;t fix it)&lt;/p&gt;</comment>
                            <comment id="696892" author="thomasr" created="Wed, 20 Aug 2014 15:27:01 +0000"  >&lt;p&gt;Hi Don,&lt;/p&gt;

&lt;p&gt;I moved this ticket over from the documentation project to SERVER, where we handle bugs and feature requests for MongoDB.&lt;/p&gt;

&lt;p&gt;Is this on a sharded environment? If so, then you may be running into &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-3645&quot; title=&quot;Sharded collection counts (on primary) can report too many results&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-3645&quot;&gt;&lt;del&gt;SERVER-3645&lt;/del&gt;&lt;/a&gt;. Counts are currently not using the chunk managers on the primaries, which would filter out the documents not &quot;owned&quot; by a shard. That means you can get counts that are higher than expected. &lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Thomas&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="49537" name="mongo_index_bug.txt" size="3090" author="dmitchell@edx.org" created="Mon, 11 Aug 2014 13:59:00 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 20 Aug 2014 15:27:01 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        8 years, 42 weeks 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>
                            8 years, 42 weeks 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>dmitchell@edx.org</customfieldvalue>
            <customfieldvalue>sam.kleinman</customfieldvalue>
            <customfieldvalue>thomas.rueckstiess@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrlpi7:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>131767</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

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

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

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