[CSHARP-1094] ReadPreference and MaxTime not honored for cursor.Count() and Size() Created: 05/Nov/14  Updated: 02/Apr/16  Resolved: 07/Nov/14

Status: Closed
Project: C# Driver
Component/s: Operations
Affects Version/s: 1.9.2
Fix Version/s: 1.10, 2.0

Type: Bug Priority: Major - P3
Reporter: Rod Adams Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: cs
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends

 Description   

C# Driver: 1.9.2
MongoDB: 2.6.5
Sharded Cluster w/ Replicas

var cursor = m_RecipientCollection.FindAs<BsonDocument>(q)
                            .SetFields(fields)
                            .SetSkip(offset)
                            .SetLimit(limit)
                            .SetSortOrder(SortBy.Descending(UserAttrId.Timestamp))
                            .SetReadPreference(ReadPreference.SecondaryPreferred);
                total = cursor.Count();

The above specifies a Read Preference of Secondary Preferred, yet the count command is sent to the primary, even when there's a perfectly responsive Secondary about, as proven by iterating cursor built the same way running against the secondary.



 Comments   
Comment by Githook User [ 07/Nov/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1094: Honor ReadPreference and MaxTime in MongoCursor Count and Size.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/89051f54564dd31b118acbd7bbebaa72db7e45de

Comment by Githook User [ 07/Nov/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1094: Honor ReadPreference and MaxTime in MongoCursor Count and Size.
Branch: v1.x
https://github.com/mongodb/mongo-csharp-driver/commit/6c752614e6a309a8e731bf86e4c9b953fffa53e1

Comment by Robert Stam [ 05/Nov/14 ]

It also needs to honor MaxTime.

Comment by Robert Stam [ 05/Nov/14 ]

I've looked at the source code and confirmed that this is true.

It is also true for cursor.Size.

Generated at Wed Feb 07 21:38:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.