in reply to Re^5: Preventing database handles from going stale
in thread Preventing database handles from going stale

It's not timing out in a matter of seconds, it just appears that DBD::Pg->ping is not sufficient as a keepalive. I'd estimate that I'm seeing a 5 minute timeout, but I haven't done any testing specifically aimed at verifying that.

The race condition I'm talking about (assuming a 5 minute timeout) is that the ping could run 4 minutes 59.999 seconds after the last query (while everything is still fine), the connection times out at 5 minutes, and then the next query (tries to) run at 5 minutes and 0.001 seconds after the previous one. eval is indeed the only way to catch that scenario and recover from it, but an ounce of prevention and all that.

Replies are listed 'Best First'.
Re^7: Preventing database handles from going stale
by kyle (Abbot) on Feb 05, 2007 at 18:28 UTC

    I think ping is implemented as a query. I sometimes see "SELECT 'DBD::Pg ping test'" in pg_stat_activity, and I can't imagine that's anything else.

      It is, I just took a peek at the source code for it, and it does a SELECT (dbd_db_ping(dbh) in dbdimp.c). I don't know why that wouldn't be enough to keep the connection alive though...Perhaps the query needs to interact with an existing table to keep the connection alive?

      __________
      The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
      - Terry Pratchett