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

If a connection times out on the client side it is left open in state CLOSE_WAIT on server side

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 1.5.5
    • Fix Version/s: None
    • Component/s: pecl-mongo
    • Labels:
      None
    • Environment:
      Clients: Ubuntu 14.04 / Mac OSX, PHP-FPM 5.4 / 5.5
      Server: Ubuntu 14.04, Mongo 2.6.4
    • # Replies:
      9
    • Last comment by Customer:
      false

      Description

      We upgraded servers from 2.4.x to 2.6.4 and this issue came up.

      We have MongoCursor::$timeout=20000 in our scripts. Unfortunately some queries do sometimes take that long and are then killed. This worked fine until upgrade. After upgrade the server does not close these connections and they are left in state CLOSE_WAIT. The server gradually becomes unresponsive and has to be restarted. Also if the client stops sending requests, the connections are closed (noticed this when trying to reproduce the situation in testing). Here is a simple script I used to reproduce this error:

      <?php
      MongoCursor::$timeout = 100;
      $mc = new MongoClient("mongodb://test-server");
      $coll = $db->test->collection;
      $reg = new MongoRegex("/^Text/i");
      $it = $coll->find(array("textfield"=> $reg));
      var_dump(iterator_to_array($it));
      ?>

      I then used siege (or ab) to stress this script with 10 concurrent connections. mongostat showed open connections on the server side going up from 18 to 1140 Performing other queries while this was going on (without the timeout) was also impossible.

      We also tried setting $timeout to -1 in production, but we then hit PHPs max_execution_time which eventually caused the same affect.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

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