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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fabrice at workdigital dot co dot uk
New email:
PHP Version: OS:

 

 [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: Fri Nov 29 03:01:28 2024 UTC