Db连接未关闭

时间:2017-10-23 16:56:16

标签: php postgresql php-pgsql

我刚刚在任何 php 7.X 数据库连接未被关闭/清理相关的bug >以下版本的版本,我希望是否有人可以提供一些有关为什么这样的行为的见解&指出任何有助于避免这种情况的 .ini 设置。

<?php 
$dbLink1 = pg_connect( "host=localhost port=5432 dbname=development", PGSQL_CONNECT_FORCE_NEW );
pg_query($dbLink1, 'select 1; /*FIRST*/');

$dbLink2 = pg_connect( "host=localhost port=5432 dbname=development", PGSQL_CONNECT_FORCE_NEW );
pg_query($dbLink2, 'select 1; /*SECOND*/');

/*closing first link*/
pg_close($dbLink1);

$dbLink2 = pg_connect( "host=localhost port=5432 dbname=development", PGSQL_CONNECT_FORCE_NEW );
pg_query($dbLink2, 'select 1; /*THIRD*/');

/*2nd 3rd connection remain idle on the database connection as long as the scripts is alive, the 2nd connection overridden by $dbLink2 should be automatically destroyed*/

sleep(200); ?>

在PHP 5.6,5.5中,我注意到所有未使用的连接都被自动清理,我只剩下数据库上的1个空闲连接,这在PHP中似乎不是这样。 7。

1 个答案:

答案 0 :(得分:0)

这是PHP7中确认的错误,将在以后的版本中修复。

详细信息:https://bugs.php.net/bug.php?id=75419

修复提交:https://github.com/php/php-src/commit/a645af44561acb4696bc9b98a656781ded81fb79