amphp / postgres

Async Postgres client for PHP based on Amp.
MIT License
97 stars 20 forks source link

Cannot set connection to nonblocking mode #43

Closed PNixx closed 1 year ago

PNixx commented 3 years ago

I see a same error on v1.3.3. I set a pool 10 connection and receive error after 1-2 minutes:

pg_connection_busy(): Cannot set connection to nonblocking mode, /project/vendor/amphp/postgres/src/PgSqlHandle.php:109

When I used pool 5, I did not observe such a problem.

Similar issue: https://github.com/amphp/postgres/issues/13

trowski commented 3 years ago

The connection may be going away, resulting in this call returning -1. Can you try reducing the idle timeout on your pool and see if that helps?

I added a check for a closed connection 34f748237f138da8d3b805de84e2767239635ed6, so you could also try with master and see if that eliminates the error, as it should close the connection, resulting in the connection being removed from the pool.

PNixx commented 3 years ago

Did not help. I see a same error:

pg_connection_busy(): Cannot set connection to nonblocking mode, /project/vendor/amphp/postgres/src/PgSqlHandle.php:117
trowski commented 3 years ago

I haven't been able to reproduce this. Any tips?

PNixx commented 3 years ago

Try connection with pgbouncer.

PNixx commented 3 years ago

I try similar errors with version 1.4.1:

pg_connection_busy(): Cannot set connection to nonblocking mode, /project/vendor/amphp/postgres/src/PgSqlHandle.php:122
PNixx commented 3 years ago

I think I have found the reason for this error. I use pgbouncer with pool 20, my php worker pool 20 and other app with pool 20. When the php worker is running at full capacity, I get this error. Because an other app uses connections too.

trowski commented 1 year ago

Sounds like this issue was due to something external to this library, so I'm closing this issue.