We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Database connection is on closed on the end of a request

Hello,

First of all Phalcon is a great framework.

I'm having the problem that database connections are not closed when the request ends. DB Backend is PostgreSQL and PGPool II beforehand. I'm using php-fpm too, so there is a resource leak with open DB connections. Also when e.g. PGPool is restarted dangling and not useable useable connections are kept. Therefore all request before the reconnect fail (e.g. when pgpool oder postgrs is restarted).

I verified it with a new super class that close is not called (see below).

MyPostgresql::__construct()

MyPostgresql::connect()

According to the docs it should be closed on the end of the request: https://docs.phalcon.io/en/latest/api/Phalcon_Db_Adapter_Pdo_Postgresql.html

public close () inherited from Phalcon\Db\Adapter\Pdo Closes the active connection returning success. Phalcon automatically closes and destroys active connections when the request ends

Version is latest stable from git repo.

Any help would be fine, if it is a bug would be great if you could fix it.

Thnx.

Ciao,

Gerhard

class MyPostgresql extends Postgresql {

/**
 * Creates the Adapter
 */
public function __construct(array $descriptor)
{
    error_log("MyPostgresql::__construct()");
    parent::__construct($descriptor);
}

/**
 * Connect
 */
public function connect($descriptor=null)
{
    error_log("MyPostgresql::connect()");
    return parent::connect($descriptor);
}

/**
 * Close
 */
public function close()
{
    error_log("MyPostgresql::close()");
    return parent::close();
}

}



1.1k
edited Dec '15

BTW: 'persistent' => 'false',

Ciao,

Gerhard



1.1k

Any Feedback?

Ciao,

Gerhard



1.1k

Any answer?

Ciao, Gerhard