phppostgresqlnetwork-programmingpdo

Possible bug with PHP PDO and with PostgreSQL


At the startup of the docker application (with laravel php), for 1 request, connection to database is fine. After the first request I start to get this error.

SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily unavailable (Connection: pgsql, SQL: (select * from ........)

Using:

I tracked down this problem until I found out that PDO is actually not openning a connection to PostgreSQL. I tested it with iptraf and both pg_connect and PDO. When we use PDO, we get the error above and but when I try to use pg_connect, we can connect and even make a query.

So my findings are, when using iptraf

[EDIT] New findings:


Solution

  • Check the php-swoole package version on your failed deployment. If it is 6.0.0 probably you have here the problem.

    Edit: We also have this problem, we deployed a container compiled from last week and one with the same code but compiled this week, the difference was that the swoole package had been updated from version 5x to 6.0.0, which is an alpha version. Mysteriously, this version has sneaked into the Ubuntu repository, not being recommended for production and its changelog indicates several changes and incompatibilities with PDO.

    From php pecl

    HOW TO SOLVE IT: Remove swoole if you don't need it. If you need it, right now the previous version is not listed on the repo, so you need to get it alternatively.