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

MongoCursor - maxTime - TimeoutException is thrown after wrong period of time

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 3.2.2
    • API
    • None

    Description

      Please have a look at following code snipped:

      MongoDatabase db = mongoClient.getDatabase("local");
      MongoCollection<Document> oplogCollection = db.getCollection("oplog.$main");
       
      MongoCursor<Document> cursor = oplogCollection.find(aFilter())
                      .cursorType(CursorType.Tailable)
                      //will throw MongoExecutionTimeoutException after ~ 10s -30s
                      .maxTime(300, MILLISECONDS)
                      .iterator();
       
      //following code will produce an exception after like 10-30s:
      cursor.hasNext(); 
      

      I tried to implement this functionality using cursor type=TailableAwait and maxAwaitTile(300, MILLISECONDS) but in such case code was just freezing without any timeout.

      Attachments

        Activity

          People

            ross@mongodb.com Ross Lawley
            krzysztofbarczyk Krzysztof Barczyk
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: