php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70509 Method MongoCursor::maxTimeMS doesn't always throw timeout exception
Submitted: 2015-09-16 10:24 UTC Modified: -
From: fabrice at workdigital dot co dot uk Assigned:
Status: Open Package: mongo (PECL)
PHP Version: 5.6.13 OS: Debian
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
8 + 34 = ?
Subscribe to this entry?

 
 [2015-09-16 10:24 UTC] fabrice at workdigital dot co dot uk
Description:
------------
Contrary as what the documentation says, MongoCursor::maxTimeMS() doesn't always throws MongoExecutionTimeoutException, it doesn't work this way when you use next() on the cursor.
See the working script examples for details!


Test script:
---------------
// Currently throwing exception (fine!)

    // Any slightly big collection should do here
    $cursor = $mongo->test->test->find(['i' => 9999999])->maxTimeMS(1);
    // $doc = iterator_to_array($cursor);
    foreach ($cursor as $item) {
        var_dump($item);
    }


// Doesn't throw an exception (bad!)
    $doc = $mongo->test->test->find(['i' => 9999999])->maxTimeMS(1)->next();
    var_dump($doc);
    // Will display:
    // array(2) {
    // '$err' =>
    // string(29) "operation exceeded time limit"
    //  'code' =>
    // int(50)
    // }



Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 04:01:29 2024 UTC