You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-06 08:49:29 +02:00
Merged issue #111: Print the real exception when DBH->connect fails.
Author: Eric Radman
This commit is contained in:
@@ -54,7 +54,7 @@ sub BackRestTestBackup_PgConnect
|
||||
BackRestTestBackup_PgDisconnect();
|
||||
|
||||
# Default
|
||||
$iWaitSeconds = defined($iWaitSeconds) ? $iWaitSeconds : 30;
|
||||
$iWaitSeconds = defined($iWaitSeconds) ? $iWaitSeconds : 20;
|
||||
|
||||
# Record the start time
|
||||
my $lTime = time();
|
||||
@@ -62,19 +62,13 @@ sub BackRestTestBackup_PgConnect
|
||||
do
|
||||
{
|
||||
# Connect to the db (whether it is local or remote)
|
||||
eval
|
||||
{
|
||||
$hDb = DBI->connect('dbi:Pg:dbname=postgres;port=' . BackRestTestCommon_DbPortGet .
|
||||
';host=' . BackRestTestCommon_DbPathGet(),
|
||||
BackRestTestCommon_UserGet(),
|
||||
undef,
|
||||
{AutoCommit => 0, RaiseError => 1});
|
||||
};
|
||||
$hDb = DBI->connect('dbi:Pg:dbname=postgres;port=' . BackRestTestCommon_DbPortGet .
|
||||
';host=' . BackRestTestCommon_DbPathGet(),
|
||||
BackRestTestCommon_UserGet(),
|
||||
undef,
|
||||
{AutoCommit => 0, RaiseError => 0, PrintError => 0});
|
||||
|
||||
if (!$@)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return if $hDb;
|
||||
|
||||
# If waiting then sleep before trying again
|
||||
if (defined($iWaitSeconds))
|
||||
@@ -84,7 +78,8 @@ sub BackRestTestBackup_PgConnect
|
||||
}
|
||||
while ($lTime > time() - $iWaitSeconds);
|
||||
|
||||
confess &log(ERROR, "unable to connect to Postgres after ${iWaitSeconds} second(s)");
|
||||
confess &log(ERROR, "unable to connect to PostgreSQL after ${iWaitSeconds} second(s):\n" .
|
||||
$DBI::errstr, ERROR_DB_CONNECT);
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
|
||||
Reference in New Issue
Block a user