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

Mongos count command should report errors in errmsg field, not cause field

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.2
    • Fix Version/s: 3.5.5
    • Component/s: Querying, Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Query 2017-03-27

      Description

      Specifying a query hint that points to a non-existent index produces a rather generic error message:

      Fatal error: Uncaught exception 'MongoDB\Driver\Exception\ConnectionException' with message 'failed on : shard0000' in app/vendor/composer/mongodb/mongodb/src/Operation/Count.php:111
      Stack trace:
      #0 app/vendor/composer/mongodb/mongodb/src/Operation/Count.php(111): MongoDB\Driver\Server->executeCommand('keywords', Object(MongoDB\Driver\Command), Object(MongoDB\Driver\ReadPreference))
      #1 app/vendor/composer/mongodb/mongodb/src/Collection.php(233): MongoDB\Operation\Count->execute(Object(MongoDB\Driver\Server))
      #2 app/scratch08.php(20): MongoDB\Collection->count(Array, Array)
      #3 {main}
        thrown in app/vendor/composer/mongodb/mongodb/src/Operation/Count.php on line 111

      It would be awesome if the error message hinted at what went wrong.

      Reproduce case:

      $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
       
      $col = new \MongoDB\Collection($manager, 'keywords', 'keywords');
       
      $res = $col->count(
          [
              '_id' => [
                  '$in' => []
              ]
          ],
          [
              'hint' => [
                  '_not_exists' => 1
              ]
          ]
      );

        Attachments

          Activity

            People

            Assignee:
            david.storch David Storch
            Reporter:
            igorwrg Igor Wiedler
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: