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

Add full maxTimeMS support to the explain command

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Gone away
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Querying, Sharding
    • Labels:
    • Sprint:
      Query 2021-01-11

      Description

      The explain command does not fully support the maxTimeMS option due to the two following issues.

      The first is that the explain shell helpers generate an explain command with the maxTimeMS parameter in the wrong location. The shell command

      db.c.find().maxTimeMS(100).explain("executionStats");
      

      generates the command:

      { explain: { find: "c", filter: {}, maxTimeMS: 100.0 }, verbosity: "executionStats" }
      

      Instead it should place maxTimeMS as a top-level parameter:

      { explain: { find: "c", filter: {} }, verbosity: "executionStats", maxTimeMS: 100.0 }
      

      The second issue is that mongos strips out the maxTimeMS before forwarding it to the shards. I can reproduce by starting a one-shard cluster and running the following against the mongos:

      db.c.drop()
      for (var i = 0; i < 10; i++) { db.c.insert({_id: i}); }
      db.runCommand({explain: {find: "c", filter: {$where: "sleep(100)"}}, verbosity: "executionStats", maxTimeMS: 1});
      

      When I run this directly against a mongod, it results in ErrorCodes::ExceededTimeLimit. But it does not time out when I run it against a mongos.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              david.storch David Storch
              Reporter:
              david.storch David Storch
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: