[JAVA-1118] Mongo Java Driver Descriptive Exception for No Primary Created: 19/Feb/14 Updated: 03/Jan/18 Resolved: 25/Nov/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API, Cluster Management |
| Affects Version/s: | 2.11.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Linda Qin | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Case: | (copied to CRM) | ||||||||||||
| Description |
|
When a replica set primary is failing and primary reads and writes are performed, a MongoException is thrown. For example:
The only way to determine the true cause is to inspect the Exeption's message field. Ideally, we should be able to recognize this exception from its type without having to inspect/pattern match against the Exception's message field.
that is only thrown in this situation. |
| Comments |
| Comment by Jeffrey Yemin [ 25/Nov/15 ] | ||||||||||||
|
Without server support there's not much a driver can do. Closing as Won't Fix. | ||||||||||||
| Comment by Jeffrey Yemin [ 01/May/14 ] | ||||||||||||
|
Without some server support, it's not clear what more we can do. | ||||||||||||
| Comment by Doug Jones [ 18/Apr/14 ] | ||||||||||||
|
Ok, I created | ||||||||||||
| Comment by Jeffrey Yemin [ 16/Apr/14 ] | ||||||||||||
|
I can't find anything doing a search. It practice I would think it would be difficult to do it cleanly in all cases, because it may be that multiple shards are involved in some operation and that operation is partially completed before mongos finds a shard with no primary and has to abort. That said, please feel free to open an issue in the SERVER project with any ideas that you have on this. | ||||||||||||
| Comment by Doug Jones [ 16/Apr/14 ] | ||||||||||||
|
Is there a plan to fix this on the server/mongos side? Any Jiras I should look at? | ||||||||||||
| Comment by Jeffrey Yemin [ 16/Apr/14 ] | ||||||||||||
|
The server has not publicly documented the error code used to indicate this condition, so the driver just throws a generic error. That "error querying server" is what's returned by mongos. | ||||||||||||
| Comment by Doug Jones [ 15/Apr/14 ] | ||||||||||||
|
Does this apply to queries that are routed through mongos? I'm trying to test this behavior in the 2.12.0 driver release and I get the following exception when no primary is available:
| ||||||||||||
| Comment by Jeffrey Yemin [ 25/Feb/14 ] | ||||||||||||
|
In 2.12.0, the driver will throw MongoServerSelectionException: https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/BaseCluster.java#L78-82. It's not quite as specific as PrimaryNotFound, but I think it will serve the purpose, and it has the advantage of being applicable not only to writes but to reads, regardless of read preference. |