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

php driver doest close connection , when catch cursor timed out exception.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 1.2.7
    • Fix Version/s: 1.2.10
    • Component/s: pecl-mongo
    • Labels:
    • Environment:
      centos 2.6.18 nginx php-fpm
    • Backwards Compatibility:
      Major Change
    • # Replies:
      1
    • Last comment by Customer:
      true

      Description

      when mongodb is io busy, multiGet from mongos catch a cursor timed out (timeout: 1000, time left: 0:0, status: 0).
      then , php-cgi reconnect mongos. but old connection hasn't been closed.

      in my test, i multiGet 10000 keys from mongo, and set timeout to be 1ms. so this will always be timed out.
      and each time php-cgi will create new connection , with old connection never be closed;

      after long time , mongos have too many connections.

      i check the php driver code, and found that

      driver called util/connect.c mongo_util_disconnect function to close connections. First, check server->owner with getpid().
      but in my case, server->owner always be 0, and the connection can't be closed;

      i found server is get from connecto poll(stack_monitor).
      util/pool.c mongo_util_pool__stack_pop

      server->connected = 1;
      server->socket = node->socket;

      only socket is set, and owner hasn't been set. so owner will be 0, and can't be closed;

      i add "server->owner = getpid();" in this function , and now it works.

      Can this modify cause any other error ??

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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