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

Mongo Java Driver Descriptive Exception for No Primary

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 2.11.2
    • API, Cluster Management
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: