mojolicious / mojo-pg

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

Mojo::Pg fails to detect dead connection and does not reconnect #63

Closed tyldum closed 4 years ago

tyldum commented 4 years ago

Steps to reproduce the behavior

On a server that has Mojo:Pg connected issue this query to close all connections: SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity

Expected behavior

Mojo::Pg should create a new socket to the server and execute query.

Actual behavior

Subsequent calls to app->pg->db->query() fails with DBD::Pg::st execute failed: no connection to the server. It will never reconnect.

tyldum commented 4 years ago

mst told me to revert commit 9b7e3bfde04c3d3022e12ea387643a78bec62a24, which is what I did in https://github.com/mojolicious/mojo-pg/compare/master...tyldum:revert-9b7e3bfde04c3d3022e12ea387643a78bec62a24

This fixes the issue for me in my lab setup.

tyldum commented 4 years ago

Updated the linked fork with a reproducible test. Can create a MR if someone wants, but I considered it too trivial at this point. Besides, the test is a bit destructive in that it will close all connections to the current database, so YMMV if it's safe in your test env.

kraih commented 4 years ago

So, it's been two weeks and nobody has done this too trivial for a PR fix?

kraih commented 4 years ago

Fixed in 4.17. But i'm still rather disappointed that this was not fixed already while i was on vacation.