[JAVA-1298] secondary readPrefs require a primary in the replica-set to retrieve more than 101 results Created: 01/Jul/14  Updated: 13/Apr/16  Resolved: 13/Apr/16

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.11.0
Fix Version/s: 2.12.0

Type: Bug Priority: Major - P3
Reporter: Andrew Ryder (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

getMore command behind DBCursor.hasNext appears to require that a primary exists in the replica-set somewhere. It does not require a connection to it (AFAIK) but it insists that a primary be nominated.

Reproduction:
1. Set up a 3 node replica-set (PSS).
2. Kill 2 nodes.
3. Run Java client with a readPreference of secondary and perform a simple query.
4. Call hasNext on the returned cursor until 101 results.
5. Stack trace follows:

Caused by: com.mongodb.MongoException: can't find a master
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:517)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:236)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:184)
at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:427)
at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:396)
at com.mongodb.DBCursor._hasNext(DBCursor.java:464)
at com.mongodb.DBCursor.hasNext(DBCursor.java:484)

It would seem the first DBTCPConnnector.call passes "null" as a readPref to the counterpart which dutifully passes that through to DBTCPConnector.innerCall which defaults to primary (because null readpref) and the getMore helper has constructed an OutMessage instance with no readpref either. Thus checkMaster is erroneously called with "true" for "failIfNoMaster".



 Comments   
Comment by Jeffrey Yemin [ 02/Jul/14 ]

This bug has been fixed in the 2.12 release as part of other larger changes to the driver, and currently we don't plan to backport to 2.11.

Comment by Jeffrey Yemin [ 01/Jul/14 ]

I reproduced the bug in 2.11.4, but it's fixed in 2.12.2.

Generated at Thu Feb 08 08:54:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.