0

我刚刚打开提交了一个与postgres数据库连接相关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 中似乎并非如此。

4

1 回答 1

0

这是 PHP7 中已确认的错误,将在未来的版本中修复。

详情:https ://bugs.php.net/bug.php?id=75419

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

于 2017-10-24T02:45:25.513 回答