<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:15:50 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-7876] Counts running against secondaries with ReadPreference of PrimaryPreferred</title>
                <link>https://jira.mongodb.org/browse/SERVER-7876</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I originally filed this issue as relating to the C# driver, but after discussing it with Robert Stam he believes it may be an issue with MongoS and suggested I refile here. The original discussion is filed as &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-640&quot; title=&quot;ReadPreference and Commands such as Count&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-640&quot;&gt;&lt;del&gt;CSHARP-640&lt;/del&gt;&lt;/a&gt; for your reference.&lt;/p&gt;

&lt;p&gt;Our situation is that since we&apos;ve upgraded to 2.2 our sharded setup has begun running all of our counts against the secondaries. This is a sharded collection of two replica sets. We have 2 servers and and an arbiter in each set. All the servers involved (config, mongoSes, and mongoDs are running 2.2.2 on Amazon Linux and/or Centos. We&apos;re running the 1.7 version of the C# driver specifying a read preference at the connection level of PrimaryPreferred. All of our queries are executing against the primary, but all of our count()&apos;s are running on the secondaries.&lt;/p&gt;

&lt;p&gt;I&apos;ve enabled Database Profiling on the collection on the secondary and I get about 400 a second of these (and only these!) type of queries which I believe are counts?&lt;/p&gt;

&lt;p&gt;/* 0 */&lt;br/&gt;
{&lt;br/&gt;
&quot;ts&quot; : ISODate(&quot;2012-12-07T16:45:27.767Z&quot;),&lt;br/&gt;
&quot;op&quot; : &quot;command&quot;,&lt;br/&gt;
&quot;ns&quot; : &quot;ourdb.$cmd&quot;,&lt;br/&gt;
&quot;command&quot; : {&lt;br/&gt;
&quot;count&quot; : &quot;OurCollection&quot;,&lt;br/&gt;
&quot;query&quot; : &lt;/p&gt;
{ &quot;pid&quot; : 1320633, &quot;vi&quot; : true }
&lt;p&gt;},&lt;br/&gt;
&quot;ntoreturn&quot; : 1,&lt;br/&gt;
&quot;keyUpdates&quot; : 0,&lt;br/&gt;
&quot;numYield&quot; : 0,&lt;br/&gt;
&quot;lockStats&quot; : {&lt;br/&gt;
&quot;timeLockedMicros&quot; : &lt;/p&gt;
{ &quot;r&quot; : NumberLong(739), &quot;w&quot; : NumberLong(0) }
&lt;p&gt;,&lt;br/&gt;
&quot;timeAcquiringMicros&quot; : &lt;/p&gt;
{ &quot;r&quot; : NumberLong(33610), &quot;w&quot; : NumberLong(2) }
&lt;p&gt;},&lt;br/&gt;
&quot;responseLength&quot; : 48,&lt;br/&gt;
&quot;millis&quot; : 0,&lt;br/&gt;
&quot;client&quot; : &quot;192.168.xx.xxx&quot;,&lt;br/&gt;
&quot;user&quot; : &quot;&quot;&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;A similar trace on the primary reveals no such counts at all, only 400/s regular get and update queries as expected. If I shutdown the secondary, the counts do move over to the primary, but when both are online I&apos;m unable to get anything but this situation. I&apos;ve tried reversing the roles of the servers and the load reverses accordingly.&lt;/p&gt;

&lt;p&gt;We also have a non-sharded replica set which I&apos;ve just checked and it doesn&apos;t seem to be exhibiting this behaviour (the primary is handling 200 queries and 200 commands per second. The secondary maybe 10 commands a second and zero queries).&lt;/p&gt;

&lt;p&gt;According to the documentation at &lt;a href=&quot;http://docs.mongodb.org/manual/applications/replication/:&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/applications/replication/:&lt;/a&gt; &quot;mongos currently does not route commands using read preferences; clients send all commands to shards&#8217; primaries. See &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-7423&quot; title=&quot;Support commands for read preference&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-7423&quot;&gt;&lt;del&gt;SERVER-7423&lt;/del&gt;&lt;/a&gt;.&quot;&lt;/p&gt;

&lt;p&gt;So, apparently, full support is being worked on for 2.3 and the situation we have now should be impossible as the commands can&apos;t go anywhere but primaries? Which leaves me quite confused.&lt;/p&gt;

&lt;p&gt;Have we misunderstood the current expected behaviour or is there an issue here? It&apos;s not a critical problem in our environment as our secondaries stay within a second or two of each other, but it&apos;s not ideal as the data can sometimes be stale on the counts if they happen quickly enough.&lt;/p&gt;

&lt;p&gt;Any clarification or assistance would be appreciated.&lt;/p&gt;</description>
                <environment></environment>
        <key id="58681">SERVER-7876</key>
            <summary>Counts running against secondaries with ReadPreference of PrimaryPreferred</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="andrew.fladmark@t101.com">Andrew Fladmark</reporter>
                        <labels>
                    </labels>
                <created>Fri, 7 Dec 2012 19:53:30 +0000</created>
                <updated>Fri, 15 Feb 2013 15:06:43 +0000</updated>
                            <resolved>Wed, 19 Dec 2012 15:04:29 +0000</resolved>
                                    <version>2.2.2</version>
                                                    <component>Sharding</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="211645" author="stennie" created="Tue, 11 Dec 2012 00:25:30 +0000"  >&lt;p&gt;Hi Andrew,&lt;/p&gt;

&lt;p&gt;If you would prefer to submit the logs privately you can create a new case in the &quot;Community Private&quot; Jira queue and attach the logs there: &lt;a href=&quot;http://jira.mongodb.org/browse/SUPPORT&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SUPPORT&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Correspondence and attachments in Community Private can only be viewed by yourself and 10gen support.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
Stephen&lt;/p&gt;</comment>
                            <comment id="211107" author="andrew.fladmark@t101.com" created="Mon, 10 Dec 2012 15:46:41 +0000"  >&lt;p&gt;Hi Randolph,&lt;/p&gt;

&lt;p&gt;I should be able to do this for you today. Do I need to attach them to this ticket publicly or is there somewhere I can submit them to you directly?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</comment>
                            <comment id="209258" author="renctan" created="Fri, 7 Dec 2012 20:22:32 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Would you be able to post the mongos log with at least level 2 verbosity when you reproduce this? And can you also tell us what is the count command that you were issuing?&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="53686">SERVER-7423</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="58630">CSHARP-640</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>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 7 Dec 2012 20:22:32 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 10 weeks, 2 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_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>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 10 weeks, 2 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_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>andrew.fladmark@t101.com</customfieldvalue>
            <customfieldvalue>randolph@mongodb.com</customfieldvalue>
            <customfieldvalue>stephen.steneker@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrnf7r:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>36128</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|ht065b:</customfieldvalue>

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