[JAVA-467] Calling setReadPreference(ReadPreference.SECONDARY) is not reading from secondary servers Created: 07/Nov/11  Updated: 01/May/14  Resolved: 19/Nov/11

Status: Closed
Project: Java Driver
Component/s: Cluster Management
Affects Version/s: None
Fix Version/s: 2.7.2

Type: Bug Priority: Major - P3
Reporter: Jason Nethercott Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File mongo.jar     Text File testMongoSecondayReads.java    
Issue Links:
Depends
is depended on by JAVA-1167 Inserting documents validates against... Closed

 Description   

In a test environment with 4 MongoDB instances, all the reads in the attached test code are executed against only the master server. This is identified by the watching the console of each of the instances, and the CPU of the machines on which the instances are running.

The call the DBCursor.getServerAddress() is not working either, it only returns a null, so that we cannot verify where the reads are being executed. (Not sure if this is related.)



 Comments   
Comment by auto [ 12/Dec/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: JAVA-467: cur.toString() should not block
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/45b2dd89505fb155af34d194205ebc8461e04e0f

Comment by auto [ 12/Dec/11 ]

Author:

{u'login': u'bwmcadams', u'name': u'Brendan W. McAdams', u'email': u'brendan@10gen.com'}

Message: Tests utterly fail with this commit; as a result, rolling back.

Revert "JAVA-467: removed call to _check() from within getServerAddress because this method should not block."

This reverts commit 9ae9483639d064a41f873b4063582c7b782000b8.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/85f0f750bb10ecb44c42204b096c039c2dd7c222

Comment by auto [ 22/Nov/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: JAVA-467: removed call to _check() from within getServerAddress because this method should not block.
It is used for information purpose and docs states it is null until data has been returned.
One example is that it made cursor.toString() block on long queries.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/9ae9483639d064a41f873b4063582c7b782000b8

Comment by Ryan Nitz [ 08/Nov/11 ]

Hi Jason,

Thanks for bringing this to our attention (and sorry about the headaches).

I attached a patched library. Can you run in your environment and confirm everything is working properly?

Thanks,

-Ryan

Comment by auto [ 08/Nov/11 ]

Author:

{u'login': u'rgnitz', u'name': u'Ryan', u'email': u'rgnitz@gmail.com'}

Message: added _check call to getServerAddress if _it is null - JAVA-467
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/daa7f7416a4facb295e6b596558a6dc57bac88b0

Comment by auto [ 08/Nov/11 ]

Author:

{u'login': u'rgnitz', u'name': u'Ryan', u'email': u'rgnitz@gmail.com'}

Message: Moved variable calls to method to fix read preference hierarchy - JAVA-467
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/253ca0772dc5cdca8c3092d62dfd434690fcf337

Comment by Jason Nethercott [ 07/Nov/11 ]

Affected version is 2.7.0, however, it's not listed in JIRA.

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