[SERVER-7876] Counts running against secondaries with ReadPreference of PrimaryPreferred Created: 07/Dec/12  Updated: 15/Feb/13  Resolved: 19/Dec/12

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.2.2
Fix Version/s: None

Type: Question Priority: Minor - P4
Reporter: Andrew Fladmark Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-7423 Support commands for read preference Closed
Related
is related to CSHARP-640 ReadPreference and Commands such as C... Closed
Participants:

 Description   

Hello,

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 CSHARP-640 for your reference.

Our situation is that since we'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'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()'s are running on the secondaries.

I'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?

/* 0 */
{
"ts" : ISODate("2012-12-07T16:45:27.767Z"),
"op" : "command",
"ns" : "ourdb.$cmd",
"command" : {
"count" : "OurCollection",
"query" :

{ "pid" : 1320633, "vi" : true }

},
"ntoreturn" : 1,
"keyUpdates" : 0,
"numYield" : 0,
"lockStats" : {
"timeLockedMicros" :

{ "r" : NumberLong(739), "w" : NumberLong(0) }

,
"timeAcquiringMicros" :

{ "r" : NumberLong(33610), "w" : NumberLong(2) }

},
"responseLength" : 48,
"millis" : 0,
"client" : "192.168.xx.xxx",
"user" : ""
}

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'm unable to get anything but this situation. I've tried reversing the roles of the servers and the load reverses accordingly.

We also have a non-sharded replica set which I've just checked and it doesn'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).

According to the documentation at http://docs.mongodb.org/manual/applications/replication/: "mongos currently does not route commands using read preferences; clients send all commands to shards’ primaries. See SERVER-7423."

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

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

Any clarification or assistance would be appreciated.



 Comments   
Comment by Stennie Steneker (Inactive) [ 11/Dec/12 ]

Hi Andrew,

If you would prefer to submit the logs privately you can create a new case in the "Community Private" Jira queue and attach the logs there: http://jira.mongodb.org/browse/SUPPORT

Correspondence and attachments in Community Private can only be viewed by yourself and 10gen support.

Cheers,
Stephen

Comment by Andrew Fladmark [ 10/Dec/12 ]

Hi Randolph,

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?

Thanks.

Comment by Randolph Tan [ 07/Dec/12 ]

Hi,

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?

Thanks!

Generated at Thu Feb 08 03:15:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.