php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66088 Connections to rrdcached are never closed
Submitted: 2013-11-13 13:09 UTC Modified: 2014-01-14 09:49 UTC
From: killing at multiplay dot co dot uk Assigned: koubel (profile)
Status: Closed Package: rrd (PECL)
PHP Version: Irrelevant OS: FreeBSD
Private report: No CVE-ID: None
 [2013-11-13 13:09 UTC] killing at multiplay dot co dot uk
Description:
------------
If rrdcached is used then the connections to the daemon are never closed resulting in more and more socket resources being consumed the more php-fpm handlers are active.

The attached patch adds support for rrdcached connections which adds:
1. rrdc_disconnect method, allowing the user to manually disconnect any active connection.
2. rrdc_persistent_connections(enabled) method which allows the user to configure rrd to support persistent connections.
3. RRDC_PERSISTENT_CONNECTIONS compile time define which allows the use to change default for persistent connections (default is disabled).
4. Module shutdown handler which always closes any active rrdcached connection
5. Request shutdown handler which closes any active rrdcached connection depending on the current rrdc persistent connection setting.

Test script:
---------------
Complete the following replacing the required variables (<host>, <file>, <options>) with valid values, then run the script via a php-fpm instance.
<?php
putenv('RRDCACHED_ADDRESS=<host>');
rrd_update('<file>', '<options>');
?>

Once run, check for open connections to <host> e.g.
netstat -an |grep <host>

You'll see ESTABLISHED connections even though the script is no longer running so doesn't require the connection any more.

Expected result:
----------------
Running the following should return no ESTABLISHED connections
netstat -na | grep <host>

Actual result:
--------------
All php-fpm instances which have run the script have an ESTABLISHED connection to <host>

Patches

rrdcached-disconnect-support (last revision 2013-11-13 13:11 UTC by killing at multiplay dot co dot uk)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-13 21:10 UTC] koubel@php.net
Automatic comment from SVN on behalf of koubel
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=332608
Log: support for the rrd cache daemon connection #66088
 [2014-01-13 21:19 UTC] koubel@php.net
-Status: Open +Status: Feedback
 [2014-01-13 21:19 UTC] koubel@php.net
In your solution, persistent connection handling is little bit complicated.
Simple and clear way is let the developer when he wants to close connection through new function rrdc_disconnect e.g. at the end of request.

Try to verify current trunk version.
 [2014-01-14 09:49 UTC] koubel@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: koubel
 [2014-01-14 09:49 UTC] koubel@php.net
New package with the extension released.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 13:01:27 2024 UTC