mojolicious / mojo-pg

Mojolicious :heart: PostgreSQL
https://metacpan.org/release/Mojo-Pg
Artistic License 2.0
99 stars 46 forks source link

pg_ready failed: connection not open #87

Open ayokh75 opened 9 months ago

ayokh75 commented 9 months ago

Steps to reproduce the behavior

Currently no systematic way found to reproduce the observed error;

Mojo app running behind HA proxy, PG Pool and 2 Postgres servers (Primary and Secondary) (Mojo app -> HA Proxy -> Pgpool -> Postgres). Under heavy DB async query load when DB cluster switches from primary to secondary the following logs are observed repeatedly and the Mojolicious server app becomes unresponsive to http requests:

Mojo::Reactor::EV: I/O watcher failed: DBD::Pg::db pg_ready failed: connection not open at /tmp/par-656d75/cache-5a13761dff7eacf51565680336f8b5781c26f7aa/inc/lib/Mojo/Pg/Database.pm line 173. DBD::Pg::db pg_notifies failed: connection not open at /tmp/par-656d75/cache-5a13761dff7eacf51565680336f8b5781c26f7aa/inc/lib/Mojo/Pg/Database.pm line 142. DBD::Pg::db pg_ready failed: connection not open at /tmp/par-656d75/cache-5a13761dff7eacf51565680336f8b5781c26f7aa/inc/lib/Mojo/Pg/Database.pm line 173.

Also the following logs are observed: Mojo::Reactor::EV: I/O watcher failed: DBD::Pg::db pg_ready failed: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. at /tmp/par-656d75/cache-d8b4d457ad057b3482a456dcf4386549533fd53d/inc/lib/Mojo/Pg/Database.pm line 173.

And the following too which means the Mojo app server has to be restarted to function again: Mojo::Reactor::EV: I/O watcher failed: DBI connect('dbname=appDb;host=localhost;port=5433','dbUser',...) failed: server closed the connection unexpectedly his probably means the server terminated abnormally before or while processing the request. at /tmp/par-656d75/cache-5a13761dff7eacf51565680336f8b5781c26f7aa/inc/lib/Mojo/Pg.pm line 73.

Expected behavior

To be able to reconnect to the DB once Postgres server is available again without restarting the Mojo app;

Actual behavior

As explained in '### Steps to reproduce the behavior' section above;

kraih commented 9 months ago

This seems hard to replicate. Doubt it will be fixed quickly.