Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-349

MongoCursorTimeoutException causes connections not to close

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.10
    • Component/s: pecl-mongo
    • Labels:
      None
    • # Replies:
      8
    • Last comment by Customer:
      true

      Description

      To reproduce:

      1. Spin up Apache + mod_php
      2. Run a script over and over that connects to Mongo, does a query, and times out (e.g., I used:

        <?php
         
        try {
            $conn = new Mongo("mongodb://localhost:27017");
            $c = $conn->test->foo;
            $c->find()->timeout(1)->next();
        }
        catch (MongoException $e) {
            echo $e->getMessage();
        }
         
        ?>

      3. Each time the connection times out, another socket will be opened to mongod.

      The problem is that server->owner isn't being set: it's 0 in mongo_util_disconnect, so when it's compared to the pid of mod_php, they are not equal so the driver doesn't close the socket.

      Note: my machine was fast enough that, even with a query timeout of 1, I had to hammer the server with writes in the shell while doing Apache requests to make the PHP client timeout trigger.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since reply:
                  8 years, 2 weeks, 4 days ago
                  Date of 1st Reply: