[JAVA-951] inconsistent behaviour between java drivers before and after version 2.7.3 Created: 20/Sep/13  Updated: 23/Jun/15  Resolved: 23/Jun/15

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

Type: New Feature Priority: Major - P3
Reporter: Kay Agahd Assignee: Unassigned
Resolution: Won't Fix Votes: 1
Labels: master, query, read-preferences, replicaset, slaveOk
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File DriverTest.java    

 Description   

We've found an iconsistent behaviour between java drivers before and after version 2.7.3 on a replica set (mongo version 2.2.3 - but doesn't matter for this issue).
Before (incl.) v2.7.3 we could read from collection A and write into collection B within the same request even if ReadPreference.SECONDARY was set on the database.

After v2.7.3 a MongoException is thrown: "not talking to master and retries used up".
Our solution is either to set ReadPreference.PRIMARY (either on the database or on the find method) or to close the request and to open a new one for the write request.

It would be nice if the connection wouldn't be tied to a mongo node dependant on the first request, because it's very hard to find the cause of the above mentioned error (imagine a much more complex business logic, which we have nailed down to one well isolated test case). It would be smarter when Mongo could automatically decide to connect to the master when a write request comes in even when ReadPreference.SECONDARY is set and return to a secondary for further read requests.

Please see attached our test class to reproduce the issue.



 Comments   
Comment by Jeffrey Yemin [ 23/Jun/15 ]

DB.requestStart/requestDone were deprecated in 2.12 and removed in 3.0, so this no longer applies.

Comment by Kay Agahd [ 20/Sep/13 ]

deleted two superfluous lines of code

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