Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1118

Mongo Java Driver Descriptive Exception for No Primary

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.11.2
    • Component/s: API, Cluster Management
    • Labels:
      None

      When a replica set primary is failing and primary reads and writes are performed, a MongoException is thrown. For example:

      Caused by: com.mongodb.MongoException: ReplicaSetMonitor no master found for set: XXXX
        at com.mongodb.MongoException.parse(MongoException.java:82) ~[mongo-java-driver-2.11.2.jar:na]
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:292) ~[mongo-java-driver-2.11.2.jar:na]
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273) ~[mongo-java-driver-2.11.2.jar:na]
        at com.mongodb.DBCursor._check(DBCursor.java:368) ~[mongo-java-driver-2.11.2.jar:na]
        at com.mongodb.DBCursor._hasNext(DBCursor.java:459) ~[mongo-java-driver-2.11.2.jar:na]
        at com.mongodb.DBCursor.hasNext(DBCursor.java:484) ~[mongo-java-driver-2.11.2.jar:na]
        at com.google.code.morphia.query.MorphiaIterator.hasNext(MorphiaIterator.java:43) ~[morphia-0.103.jar:na]
        at com.google.code.morphia.query.QueryImpl.get(QueryImpl.java:416) ~[morphia-0.103.jar:na]
      

      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.
      For example, there could be a new Exception

      PrimaryNotFound extends MongoException
      

      that is only thrown in this situation.

            Assignee:
            Unassigned Unassigned
            Reporter:
            linda.qin@mongodb.com Linda Qin
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: