Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-33542

Using maxTime() on MongoDB 3.4 and 3.6 does not yield the same error code

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.4, 3.7.4
    • Affects Version/s: 3.6.0, 3.6.3
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • v3.6
    • Hide
      use test
      db.test.insert({a: 1})
      db.test.find({$where: "sleep(101)"}).maxTimeMS(100)
      
      Show
      use test db.test.insert({a: 1}) db.test.find({$where: "sleep(101)" }).maxTimeMS(100)
    • Query 2018-03-12, Query 2018-03-26

      Using maxTime() does not yield the same exception when accessing a MongoDB deployment. It seems that timeouts now throw an error code 96 instead of 50 in recent versions of the MongoDB server.

      In the Java driver it makes the driver throw a MongoQueryException instead of a MongoExecutionTimeoutException.

      Sample Java code:

      MongoDatabase db = (new MongoClient()).getDatabase("foo");
      MongoCollection<Document> coll = db.getCollection("bar");
      coll.insertOne(new Document());
      coll.find(Filters.eq("$where", "sleep(100)")).maxTime(100, TimeUnit.MILLISECONDS).first();
      

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            charles.sarrazin@mongodb.com Charles Sarrazin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: