mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Merged issue #111: Print the real exception when DBH->connect fails.
Author: Eric Radman
This commit is contained in:
parent
f210fe99c3
commit
dcad0f7007
@ -45,6 +45,7 @@ use constant
|
||||
ERROR_PATH_OPEN => 128,
|
||||
ERROR_PATH_SYNC => 129,
|
||||
ERROR_FILE_MISSING => 130,
|
||||
ERROR_DB_CONNECT => 132,
|
||||
|
||||
ERROR_UNKNOWN => 199
|
||||
};
|
||||
@ -55,7 +56,7 @@ our @EXPORT = qw(ERROR_ASSERT ERROR_CHECKSUM ERROR_CONFIG ERROR_FILE_INVALID ERR
|
||||
ERROR_RESTORE_PATH_NOT_EMPTY ERROR_FILE_OPEN ERROR_FILE_READ ERROR_PARAM_REQUIRED ERROR_ARCHIVE_MISMATCH
|
||||
ERROR_ARCHIVE_DUPLICATE ERROR_VERSION_NOT_SUPPORTED ERROR_PATH_CREATE ERROR_COMMAND_INVALID ERROR_HOST_CONNECT
|
||||
ERROR_UNKNOWN ERROR_LOCK_ACQUIRE ERROR_BACKUP_MISMATCH ERROR_FILE_SYNC ERROR_PATH_OPEN ERROR_PATH_SYNC
|
||||
ERROR_FILE_MISSING);
|
||||
ERROR_FILE_MISSING ERROR_DB_CONNECT);
|
||||
|
||||
####################################################################################################################################
|
||||
# CONSTRUCTOR
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user