<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:03:38 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-3645] Sharded collection counts (on primary) can report too many results</title>
                <link>https://jira.mongodb.org/browse/SERVER-3645</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;h3&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h3&gt;
&lt;p&gt;Count does not filter out unowned (orphaned) documents and can therefore report larger values than one will find via a normal query, or using itcount() in the shell.&lt;/p&gt;

&lt;h3&gt;&lt;a name=&quot;Causes&quot;&gt;&lt;/a&gt;Causes&lt;/h3&gt;
&lt;p&gt;The following conditions can lead to counts being off:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Active migrations&lt;/li&gt;
	&lt;li&gt;Orphaned documents (left from failed migrations)&lt;/li&gt;
	&lt;li&gt;Non-Primary read preferences (see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5931&quot; title=&quot;Secondary reads in sharded clusters need stronger consistency&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5931&quot;&gt;&lt;del&gt;SERVER-5931&lt;/del&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;&lt;a name=&quot;Workaround&quot;&gt;&lt;/a&gt;Workaround&lt;/h3&gt;
&lt;p&gt;A workaround to get accurate counts is to ensure all migrations have been &lt;a href=&quot;http://docs.mongodb.org/manual/reference/command/cleanupOrphaned/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;cleaned up&lt;/a&gt; and no migrations are active. To query non-primaries you must also ensure that there is no replication lag including any migration data, in addition to the above requirements.&lt;/p&gt;

&lt;h2&gt;&lt;a name=&quot;NonPrimaryReads&quot;&gt;&lt;/a&gt;Non-Primary Reads&lt;/h2&gt;
&lt;p&gt;For issues with counts/reads from non-primaries please see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5931&quot; title=&quot;Secondary reads in sharded clusters need stronger consistency&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5931&quot;&gt;&lt;del&gt;SERVER-5931&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;&lt;a name=&quot;Behaviorof%22fastcount%22andnon%22fastcount%22&quot;&gt;&lt;/a&gt;Behavior of &quot;fast count&quot; and non-&quot;fast count&quot;&lt;/h2&gt;
&lt;p&gt;A &quot;fast count&quot; is a count run without a predicate. It is &quot;fast&quot; because the implementation only reads the metadata, without fetching any documents.&lt;/p&gt;

&lt;p&gt;The problem of &lt;tt&gt;count()&lt;/tt&gt; reporting inaccurate results has been fixed for non-&quot;fast counts,&quot; that is, starting in 4.0, counts which are run with a predicate are accurate when run on sharded clusters. &quot;Fast counts&quot; (&lt;tt&gt;count()&lt;/tt&gt; run without a predicate) may still report too many documents (see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-33753&quot; title=&quot;count without predicate should be sharding aware&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-33753&quot;&gt;SERVER-33753&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;In general, if one needs an accurate count of how many documents are in a collection, we do not recommend using the &lt;tt&gt;count&lt;/tt&gt; command. Instead, we suggest using the &lt;tt&gt;$count&lt;/tt&gt; aggregation stage, like this:&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.foo.aggregate([{$count: &quot;nDocs&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;p&gt;See &lt;a href=&quot;https://docs.mongodb.com/manual/reference/operator/aggregation/count/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For users who need the performance of &quot;fast count&quot;, and are okay with approximate results, we suggest using $collStats instead of the count command:&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.matrices.aggregate( [ { $collStats: { count: { } } } ] )&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</description>
                <environment></environment>
        <key id="21174">SERVER-3645</key>
            <summary>Sharded collection counts (on primary) can report too many results</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="ian.boros@mongodb.com">Ian Boros</assignee>
                                    <reporter username="greg_10gen">Greg Studer</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Aug 2011 16:57:37 +0000</created>
                <updated>Thu, 27 Oct 2022 18:39:31 +0000</updated>
                            <resolved>Fri, 30 Mar 2018 15:40:46 +0000</resolved>
                                                    <fixVersion>3.7.4</fixVersion>
                                    <component>Querying</component>
                                        <votes>52</votes>
                                    <watches>89</watches>
                                                                                                                <comments>
                            <comment id="2170526" author="asya" created="Tue, 5 Mar 2019 04:53:25 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=lucasoares&quot; class=&quot;user-hover&quot; rel=&quot;lucasoares&quot;&gt;lucasoares&lt;/a&gt; this was a pretty large change, so we currently don&apos;t have plans to backport it.&lt;/p&gt;</comment>
                            <comment id="2162972" author="lucasoares" created="Tue, 26 Feb 2019 15:09:08 +0000"  >&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;This will be backported to 3.6?&lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;</comment>
                            <comment id="1850187" author="xgen-internal-githook" created="Fri, 30 Mar 2018 15:39:38 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;ian.boros@10gen.com&apos;, &apos;name&apos;: &apos;Ian Boros&apos;}
&lt;p&gt;Message: &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; make count() with a predicate accurate on sharded clusters&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/82fce7bd6f6e2838ce3ccc72474ff8b8ebe325a0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/82fce7bd6f6e2838ce3ccc72474ff8b8ebe325a0&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1845906" author="xgen-internal-githook" created="Mon, 26 Mar 2018 22:19:18 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;ian.boros@10gen.com&apos;, &apos;name&apos;: &apos;Ian Boros&apos;}
&lt;p&gt;Message: Revert 0c082a81047cee66821e295d02e3588f7934ff64: &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;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/6e0fb3da005b6fbe14b30c28bf3a148412635150&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/6e0fb3da005b6fbe14b30c28bf3a148412635150&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1841376" author="ian@10gen.com" created="Wed, 21 Mar 2018 21:52:11 +0000"  >&lt;p&gt;Apologies for the additional email, but something about JIRA&apos;s underlying DB got out of sync so I&apos;m reopening and closing this to get the ticket into the correct resolved state.&lt;/p&gt;</comment>
                            <comment id="1840830" author="mgmuscari" created="Wed, 21 Mar 2018 15:39:05 +0000"  >&lt;p&gt;Unsubscribe&lt;br/&gt;
On Wed, Mar 21, 2018 at 7:43 AM Githook User (JIRA) &amp;lt;jira@mongodb.org&amp;gt;&lt;/p&gt;
</comment>
                            <comment id="1840828" author="ian.boros" created="Wed, 21 Mar 2018 15:39:02 +0000"  >&lt;p&gt;See &quot;Behavior of &quot;fast count&quot; and non-&quot;fast count&quot; section in the description for the behavior for 4.0 on.&lt;/p&gt;</comment>
                            <comment id="1840727" author="xgen-internal-githook" created="Wed, 21 Mar 2018 14:42:28 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;ian.boros@10gen.com&apos;, &apos;name&apos;: &apos;Ian Boros&apos;}
&lt;p&gt;Message: &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; make count() with a predicate accurate on sharded clusters&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/0c082a81047cee66821e295d02e3588f7934ff64&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/0c082a81047cee66821e295d02e3588f7934ff64&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1768024" author="charlie.swanson" created="Mon, 8 Jan 2018 19:46:11 +0000"  >&lt;p&gt;This came up again during work on &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-31785&quot; title=&quot;Use multiple shards in sharded collections passthroughs&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-31785&quot;&gt;&lt;del&gt;SERVER-31785&lt;/del&gt;&lt;/a&gt;. Putting this back in &quot;Needs Triage&quot; so we can re-evaluate the priority.&lt;/p&gt;</comment>
                            <comment id="1519061" author="hmorch" created="Wed, 8 Mar 2017 17:01:18 +0000"  >&lt;p&gt;This is a 6&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/warning.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; years old bug flagged as Major. Finally somebody is looking into it. Thanks.&lt;br/&gt;
Anyway the assignee is still &quot;Backlog&quot;. Maybe it&apos;s fixed after another 6 years.&lt;/p&gt;</comment>
                            <comment id="1084276" author="farid.sharipov@basware.com" created="Tue, 10 Nov 2015 13:51:56 +0000"  >&lt;p&gt;In our case we are seeing this problem in un-sharded collection with Mongo 3.0&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;   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.messages.count()&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;15&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;mongos&amp;gt; db.messages.count()&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;15&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.count()&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;15&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find({})&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;mongos&amp;gt; db.messages.findOne()&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;null&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;mongos&amp;gt; db.messages.count()&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;15&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;mongos&amp;gt; db.messages.count()&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;15&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;mongos&amp;gt; db.messages.count()&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;15&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;mongos&amp;gt; db.messages.count()&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;15&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find()&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;mongos&amp;gt; db.messages.find().count()&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;15&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                            <comment id="1072621" author="markus.mahlberg@icloud.com" created="Wed, 28 Oct 2015 12:03:51 +0000"  >&lt;p&gt;Interestingly, an aggregation counting the documents returns the correct value:&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.collection.aggregate({$group:{_id:&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&quot;uniqueDocs&quot;&lt;/span&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;,count:{$sum: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;
</comment>
                            <comment id="930614" author="digi604" created="Wed, 3 Jun 2015 16:05:41 +0000"  >&lt;p&gt;this bug cost me almost a week as i tried to understand why my import numbers differed from my source...&lt;/p&gt;</comment>
                            <comment id="781653" author="jonhyman" created="Tue, 9 Dec 2014 10:14:38 +0000"  >&lt;p&gt;Do you know if this is going to make it into 2.8? We have a 6 hour balancer window and our counts can be wrong during 25% of the day due to it.&lt;/p&gt;</comment>
                            <comment id="674255" author="justanyone" created="Mon, 28 Jul 2014 22:50:01 +0000"  >&lt;p&gt;@Sam Flint - THANK YOU, that  explain().n saves a bunch of time!  Great hint!&lt;/p&gt;</comment>
                            <comment id="672816" author="sflint@sailthru.com" created="Sun, 27 Jul 2014 15:47:56 +0000"  >&lt;p&gt;You can use explain() to capture the correct count and this is much faster than itcount(). We put this in our client side application to call explain().n&lt;br/&gt;
As you can see it is accurate and it is faster than itcount().&lt;br/&gt;
&quot;cursor&quot; : &quot;BtreeCursor client_id_1_lists_1_order_1&quot;,&lt;br/&gt;
&quot;n&quot; : 5487153,&lt;br/&gt;
&quot;nChunkSkips&quot; : 17072,&lt;br/&gt;
&quot;nYields&quot; : 11907,&lt;br/&gt;
&quot;nscanned&quot; : 5672905,&lt;br/&gt;
&quot;nscannedAllPlans&quot; : 5672905,&lt;br/&gt;
&quot;nscannedObjects&quot; : 5672905,&lt;br/&gt;
&quot;nscannedObjectsAllPlans&quot; : 5672905,&lt;br/&gt;
&quot;millisShardTotal&quot; : 69749,&lt;br/&gt;
&quot;millisShardAvg&quot; : 9964,&lt;br/&gt;
&quot;numQueries&quot; : 7,&lt;br/&gt;
&quot;numShards&quot; : 7,&lt;br/&gt;
&quot;millis&quot; : 18282&lt;br/&gt;
}&lt;br/&gt;
mongos&amp;gt; db.profile.find(&lt;/p&gt;
{client_id : 3762}
&lt;p&gt;,&lt;/p&gt;
{client_id:1}
&lt;p&gt;).count()&lt;br/&gt;
5503724&lt;br/&gt;
mongos&amp;gt; db.profile.find(&lt;/p&gt;
{client_id : 3762}
&lt;p&gt;,&lt;/p&gt;
{client_id:1}
&lt;p&gt;).itcount()&lt;br/&gt;
5487153&lt;br/&gt;
mongos&amp;gt; db.profile.find(&lt;/p&gt;
{client_id : 3762}
&lt;p&gt;,&lt;/p&gt;
{client_id:1}
&lt;p&gt;).explain().n&lt;br/&gt;
5487153&lt;/p&gt;</comment>
                            <comment id="561497" author="srinivas.mutyala@citi.com" created="Thu, 24 Apr 2014 12:43:50 +0000"  >&lt;p&gt;Additional issues with Sharded set-up &amp;amp; when it&apos;s sharding.&lt;/p&gt;

&lt;p&gt;1)	After the MongoDB Initial sync, the number of  documents in the individual shards are nearly equal &#8211; but not exactly.&lt;/p&gt;

&lt;p&gt;2)	During the sync in progress, if we query the total number of documents thru the mongos(router) we&#8217;re seeing indefinite results. Ideally, it should be same number all the time.If the issue is with count() is fine, but what about the data consistency.&lt;/p&gt;

&lt;p&gt;3)	Initial sync time is directly proportional to the total data size and very slower. Need a fix for it.&lt;/p&gt;</comment>
                            <comment id="479918" author="asya" created="Thu, 9 Jan 2014 23:28:08 +0000"  >&lt;p&gt;This ticket is tracking count() - which uses metadata for collection to quickly get the total count of documents.&lt;/p&gt;

&lt;p&gt;There is a different ticket tracking the fact that when you query secondaries with broadcast query (i.e. untargeted, not involving the shard key) and there is either migration in progress or orphan documents left from an aborted migration, the secondary doesn&apos;t know to filter them out the way the primary would.  That ticket is &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5931&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-5931&lt;/a&gt; - the workaround of reading from primaries when using non-targeted queries will work for you.  If you are using targeted queries (one with the shard key) then this should be a problem whether you are on primaries or secondaries.&lt;/p&gt;</comment>
                            <comment id="479914" author="jonhyman" created="Thu, 9 Jan 2014 23:20:34 +0000"  >&lt;p&gt;No, I have a query criteria. I see; I only get the issues when using secondary reads, so perhaps it is something unrelated to this issue. I patched my driver (Moped) to print out information, here&apos;s what I got from a count. Though as I mentioned, I can also reproduce this when querying over the data and incrementing my own counter, so it&apos;s not just on a count().&lt;/p&gt;

&lt;p&gt;As far as I can tell, when it is bad, it is always the same shard. ObjectRocket, our hosting provider, pointed me to this issue but perhaps we can troubleshoot separately.&lt;/p&gt;

&lt;p&gt;GOOD (returns a count of 101844)&lt;/p&gt;

&lt;p&gt;Response &lt;span class=&quot;error&quot;&gt;&amp;#91;225, -645272788, 23, 1, 0, 0, 0, 1&amp;#93;&lt;/span&gt;&lt;br/&gt;
reply doc {&quot;shards&quot;=&amp;gt;&lt;/p&gt;
{&quot;2f7abb37320b715c8ed68c86d29d93a7&quot;=&amp;gt;25754, &quot;cabe9e1b214ce57538a20ca6688a8ee0&quot;=&amp;gt;25300, &quot;dcb91ad1cd3630601020f83d7b6883e0&quot;=&amp;gt;25581, &quot;f1678636cab6fa77c76a9264ea9963a7&quot;=&amp;gt;25209}, &quot;n&quot;=&amp;gt;101844, &quot;ok&quot;=&amp;gt;1.0}&lt;br/&gt;
Operation #&amp;lt;Moped::Protocol::Command&lt;br/&gt;
  @length=145&lt;br/&gt;
  @request_id=23&lt;br/&gt;
  @response_to=0&lt;br/&gt;
  @op_code=2004&lt;br/&gt;
  @flags=&lt;span class=&quot;error&quot;&gt;&amp;#91;:slave_ok&amp;#93;&lt;/span&gt;&lt;br/&gt;
  @full_collection_name=&quot;REDACTED.$cmd&quot;&lt;br/&gt;
  @skip=0&lt;br/&gt;
  @limit=-1&lt;br/&gt;
  @selector={:count=&amp;gt;&quot;COLLECTION_REDACTED&quot;, :query=&amp;gt;{REDACTED}&lt;br/&gt;
  @fields=nil&amp;gt;, reply #&amp;lt;Moped::Protocol::Reply&lt;br/&gt;
  @length=225&lt;br/&gt;
  @request_id=-645272788&lt;br/&gt;
  @response_to=23&lt;br/&gt;
  @op_code=1&lt;br/&gt;
  @flags=[]&lt;br/&gt;
  @cursor_id=0&lt;br/&gt;
  @offset=0&lt;br/&gt;
  @count=1&lt;br/&gt;
  @documents=[{&quot;shards&quot;=&amp;gt;{&quot;2f7abb37320b715c8ed68c86d29d93a7&quot;=&amp;gt;25754, &quot;cabe9e1b214ce57538a20ca6688a8ee0&quot;=&amp;gt;25300, &quot;dcb91ad1cd3630601020f83d7b6883e0&quot;=&amp;gt;25581, &quot;f1678636cab6fa77c76a9264ea9963a7&quot;=&amp;gt;25209}
&lt;p&gt;, &quot;n&quot;=&amp;gt;101844, &quot;ok&quot;=&amp;gt;1.0}]&amp;gt;&lt;br/&gt;
 =&amp;gt; 101844&lt;/p&gt;


&lt;p&gt;BAD (returns a count of 99503)&lt;/p&gt;

&lt;p&gt;Response &lt;span class=&quot;error&quot;&gt;&amp;#91;225, -645270088, 24, 1, 0, 0, 0, 1&amp;#93;&lt;/span&gt;&lt;br/&gt;
reply doc {&quot;shards&quot;=&amp;gt;&lt;/p&gt;
{&quot;2f7abb37320b715c8ed68c86d29d93a7&quot;=&amp;gt;23413, &quot;cabe9e1b214ce57538a20ca6688a8ee0&quot;=&amp;gt;25300, &quot;dcb91ad1cd3630601020f83d7b6883e0&quot;=&amp;gt;25581, &quot;f1678636cab6fa77c76a9264ea9963a7&quot;=&amp;gt;25209}, &quot;n&quot;=&amp;gt;99503, &quot;ok&quot;=&amp;gt;1.0}&lt;br/&gt;
Operation #&amp;lt;Moped::Protocol::Command&lt;br/&gt;
  @length=145&lt;br/&gt;
  @request_id=24&lt;br/&gt;
  @response_to=0&lt;br/&gt;
  @op_code=2004&lt;br/&gt;
  @flags=&lt;span class=&quot;error&quot;&gt;&amp;#91;:slave_ok&amp;#93;&lt;/span&gt;&lt;br/&gt;
  @full_collection_name=&quot;REDACTED.$cmd&quot;&lt;br/&gt;
  @skip=0&lt;br/&gt;
  @limit=-1&lt;br/&gt;
  @selector={:count=&amp;gt;&quot;COLLECTION_REDACTED&quot;, :query=&amp;gt;{REDACTED}&lt;br/&gt;
  @fields=nil&amp;gt;, reply #&amp;lt;Moped::Protocol::Reply&lt;br/&gt;
  @length=225&lt;br/&gt;
  @request_id=-645270088&lt;br/&gt;
  @response_to=24&lt;br/&gt;
  @op_code=1&lt;br/&gt;
  @flags=[]&lt;br/&gt;
  @cursor_id=0&lt;br/&gt;
  @offset=0&lt;br/&gt;
  @count=1&lt;br/&gt;
  @documents=[{&quot;shards&quot;=&amp;gt;{&quot;2f7abb37320b715c8ed68c86d29d93a7&quot;=&amp;gt;23413, &quot;cabe9e1b214ce57538a20ca6688a8ee0&quot;=&amp;gt;25300, &quot;dcb91ad1cd3630601020f83d7b6883e0&quot;=&amp;gt;25581, &quot;f1678636cab6fa77c76a9264ea9963a7&quot;=&amp;gt;25209}
&lt;p&gt;, &quot;n&quot;=&amp;gt;99503, &quot;ok&quot;=&amp;gt;1.0}]&amp;gt;&lt;br/&gt;
=&amp;gt; 99503&lt;/p&gt;</comment>
                            <comment id="479908" author="asya" created="Thu, 9 Jan 2014 23:14:46 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jonhyman&quot; class=&quot;user-hover&quot; rel=&quot;jonhyman&quot;&gt;jonhyman&lt;/a&gt; are these straight count() without a condition?  This is &lt;b&gt;not&lt;/b&gt; tied to secondary reads - during migrations the same documents exist on more than one shard (on the primary) on a perfectly functioning system.  &lt;/p&gt;</comment>
                            <comment id="479887" author="jonhyman" created="Thu, 9 Jan 2014 22:38:08 +0000"  >&lt;p&gt;Hi there,&lt;/p&gt;

&lt;p&gt;We just noticed this bug (it&apos;s been happening for a long time from our logs). We have a sharded setup and run a count over some documents using secondary reads.&lt;/p&gt;

&lt;p&gt;While troubleshooting, I noticed that even if I iterated over the query and incremented my own counter, I would get the same wrong result part of the time. It&apos;s extremely sporadic, I&apos;ll go periods of the day where if I run the same query over and over again, it returns the correct count every other query and the incorrect count every other query. &lt;/p&gt;

&lt;p&gt;The problem here is now I&apos;m extremely distrusting of secondary reads. Our application uses secondary reads in a lot of places because we have hundreds of millions of documents. It seems like I need to remove all secondary read preferences from my data. Does that seem like the right solution to you? If so, this is horrible IMO and secondary reads are broken in the worst way (silently returning incorrect data).&lt;/p&gt;</comment>
                            <comment id="452736" author="dan@10gen.com" created="Wed, 6 Nov 2013 23:55:13 +0000"  >&lt;p&gt;This is a major change and unfortunately did not make the cut for 2.6&lt;/p&gt;</comment>
                            <comment id="451846" author="foobar2k" created="Tue, 5 Nov 2013 20:35:05 +0000"  >&lt;p&gt;Is a fix for this targeted for 2.6? &lt;/p&gt;</comment>
                            <comment id="58596" author="auto" created="Wed, 5 Oct 2011 15:41:42 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;gregstuder&apos;, u&apos;name&apos;: u&apos;gregs&apos;, u&apos;email&apos;: u&apos;greg@10gen.com&apos;}
&lt;p&gt;Message: buildbot fix test b/c of &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; on migrates&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/d8f91a17afa59a31222eeb377690a88af74be498&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/d8f91a17afa59a31222eeb377690a88af74be498&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="49311" author="eliot" created="Thu, 18 Aug 2011 17:41:33 +0000"  >&lt;p&gt;We can&apos; do a real count - need to count more meta data&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="33575">SERVER-5366</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="39389">SERVER-5902</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                                                <inwardlinks description="is documented by">
                                        <issuelink>
            <issuekey id="520997">DOCS-11534</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="1376906">SERVER-48685</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="285039">SERVER-24079</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="36790">SERVER-5665</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="62027">SERVER-8178</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="63754">SERVER-8405</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="102123">SERVER-12082</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="155517">SERVER-15092</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="315152">SERVER-26038</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="395999">SERVER-29742</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="143157">SERVER-14319</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                        <issuelink>
            <issuekey id="677906">SERVER-39191</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="507965">SERVER-33753</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="39607">SERVER-5931</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="119094">SERVER-13116</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2165658">SERVER-70810</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="417327">SERVER-30708</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="68074">SERVER-8948</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="318804">SERVER-26316</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1469386">SERVER-50857</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>25.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[500A000000XWO9XIAX, 500A000000UaR9pIAF, 500A000000UaVzoIAF, 500A000000UaSUhIAN, 500A000000YRqwBIAT, 500A000000UaXiTIAV, 500A000000ZPOjJIAX, 500A000000aqyEqIAI, 500A000000bWg4nIAC, 5002K00000dYm3JQAS, 5002K00000ejQkuQAE, 5002K00000gm1k1QAA, 5002K00000kriSrQAI, 5002K00000oau8FQAQ]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 18 Aug 2011 17:41:33 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 49 weeks, 1 day 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>charlie.swanson@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 49 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>

                        </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="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>charlie.swanson@mongodb.com</customfieldvalue>
            <customfieldvalue>dan@mongodb.com</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>farid.sharipov@basware.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>greg_10gen</customfieldvalue>
            <customfieldvalue>hmorch</customfieldvalue>
            <customfieldvalue>ian.boros@mongodb.com</customfieldvalue>
            <customfieldvalue>ian@mongodb.com</customfieldvalue>
            <customfieldvalue>foobar2k</customfieldvalue>
            <customfieldvalue>jonhyman</customfieldvalue>
            <customfieldvalue>justanyone</customfieldvalue>
            <customfieldvalue>lucasoares</customfieldvalue>
            <customfieldvalue>markus.mahlberg@icloud.com</customfieldvalue>
            <customfieldvalue>mgmuscari</customfieldvalue>
            <customfieldvalue>digi604</customfieldvalue>
            <customfieldvalue>sflint@sailthru.com</customfieldvalue>
            <customfieldvalue>srinivas.mutyala@citi.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrot7r:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3924</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="2121">Query 2018-03-12</customfieldvalue>
    <customfieldvalue id="2122">Query 2018-03-26</customfieldvalue>
    <customfieldvalue id="2128">Query 2018-04-09</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|hrp7lr:</customfieldvalue>

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