-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Session Management
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.