mojolicious/mojo-pg

pg_ready failed: connection not open

ayokh75 opened this issue · 1 comments

  • Mojo::Pg version: 4.27
  • Perl version: 5.32
  • Operating system: Red Hat Enterprise Linux 8.8 (Ootpa)

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

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