Don't die when Postgres is down.
Noticed during tests that sometimes when the `t/20-postgres.t` tests failed,
the `bucardo.mcp.pid` file was left in place. Even though the MCP was gone.
This prevented subsequent tests from running, as they couldn't start the MCP
(Bucardo thought it was still running, because the PID file was still there).
Looking through the log, I noticed that the connection to the database was
dying in `cleanup_mcp()`. Not sure why, but the log said:
(78512) [Mon Oct 22 12:01:17.638 2012] #0578 MCP Warning: Killed (line 6722): DBD::Pg::db selectcol_arrayref failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request. at /Users/david/dev/postgresql/bucardo/blib/lib/Bucardo.pm line 6722.
That was dying, and the subsequent lines that actually delete the PID file
were therefore never run.
This commit wraps the call to the database in an `eval{}`. If it dies, the
database shutdown time is set to "unknown". We skip further database
interactions when the time is unknown. This allows the shutdown to continue
without exiting, and the MCP PID file gets cleaned up.
Resolves #26.