D
daniel.crosby
The eval does not seem to be enough to provoke a timeout on a hanging
oracle connection i.e. where i get no response. I do not understand why
this does not work in this perl example.
foreach $l_db (keys %{ $G_ALL_DB{$l_host}}) {
($l_ars, $l_ars_sev)= split /\|/, $G_ALL_DB{$l_host}{$l_db};
$l_startdb=time(); # = now
$G_COUNT_DB_CONNECT++;
eval { ### TRY ###
$l_erg="";
$l_exe_ok=0;
use DBI;
$ENV{ORACLE_HOME}=$G_CONF{DBHOME};
$SIG{ALRM} = sub {&ConnectTimeOut ($l_host, $l_db, $l_ars,
$l_ars_sev, $l_erg) };
alarm $G_CONF{TIMEOUT_DB_CONNECT};
$l_cstr="DBI:Oracle:$l_db";
$l_dbh = DBI->connect($l_cstr, $G_CONF{TEST_USER},
$G_CONF{TEST_PASS}, { PrintError=>0, RaiseError=>0, AutoCommit=>1 });
if ($l_dbh) {
if ($l_results= $l_dbh->prepare ($G_SEL_TIV_CONN_CHECK )) {
$l_results->execute;
$l_exe_ok=1;
# fetch rows
while (@l_row = $l_results->fetchrow_array) {
$l_erg=$l_row[0];
if ( $l_erg !~ /XOK/ ) {
$l_msg="$l_db Result doesn't match XOK";
@l_errstr=();
&ConnectFailed ($l_host, $l_db, $l_ars, $l_ars_sev, $l_msg,
@l_errstr);
} else {
&Logging (3, $I, $l_db, "Connect success. DB = $l_db");
$G_RESULTS_CONNECT{$l_db}="connect_succeeded";
}
}
}
$l_dbh->disconnect or &warn ("Can not close DB $l_db,
$DBI::errstr\n");
}
alarm 0;
};
if ($@) { ### CATCH exception ###
$l_err = $@;
$l_err =~ s/\n/ /g;
$l_msg = "$l_db Exception connecting : $l_err";
# Check for errors to ignore, alert the Rest
@l_errstr = grep $DBI::errstr =~ m/$_/, keys
%G_IGNORE_ORACLE_ERRORS;
&ConnectFailed ($l_host, $l_db, $l_ars, $l_ars_sev, $l_msg,
@l_errstr );
# &Logging (0, $A, "exception", $l_msg);
}
if ( $l_exe_ok != 1 ) {
$l_msg="$l_db Connect failure : $DBI::errstr";
# Check for errors to ignore, alert the Rest
@l_errstr = grep $DBI::errstr =~ m/$_/, keys
%G_IGNORE_ORACLE_ERRORS;
&ConnectFailed ($l_host, $l_db, $l_ars, $l_ars_sev, $l_msg,
@l_errstr );
}
oracle connection i.e. where i get no response. I do not understand why
this does not work in this perl example.
foreach $l_db (keys %{ $G_ALL_DB{$l_host}}) {
($l_ars, $l_ars_sev)= split /\|/, $G_ALL_DB{$l_host}{$l_db};
$l_startdb=time(); # = now
$G_COUNT_DB_CONNECT++;
eval { ### TRY ###
$l_erg="";
$l_exe_ok=0;
use DBI;
$ENV{ORACLE_HOME}=$G_CONF{DBHOME};
$SIG{ALRM} = sub {&ConnectTimeOut ($l_host, $l_db, $l_ars,
$l_ars_sev, $l_erg) };
alarm $G_CONF{TIMEOUT_DB_CONNECT};
$l_cstr="DBI:Oracle:$l_db";
$l_dbh = DBI->connect($l_cstr, $G_CONF{TEST_USER},
$G_CONF{TEST_PASS}, { PrintError=>0, RaiseError=>0, AutoCommit=>1 });
if ($l_dbh) {
if ($l_results= $l_dbh->prepare ($G_SEL_TIV_CONN_CHECK )) {
$l_results->execute;
$l_exe_ok=1;
# fetch rows
while (@l_row = $l_results->fetchrow_array) {
$l_erg=$l_row[0];
if ( $l_erg !~ /XOK/ ) {
$l_msg="$l_db Result doesn't match XOK";
@l_errstr=();
&ConnectFailed ($l_host, $l_db, $l_ars, $l_ars_sev, $l_msg,
@l_errstr);
} else {
&Logging (3, $I, $l_db, "Connect success. DB = $l_db");
$G_RESULTS_CONNECT{$l_db}="connect_succeeded";
}
}
}
$l_dbh->disconnect or &warn ("Can not close DB $l_db,
$DBI::errstr\n");
}
alarm 0;
};
if ($@) { ### CATCH exception ###
$l_err = $@;
$l_err =~ s/\n/ /g;
$l_msg = "$l_db Exception connecting : $l_err";
# Check for errors to ignore, alert the Rest
@l_errstr = grep $DBI::errstr =~ m/$_/, keys
%G_IGNORE_ORACLE_ERRORS;
&ConnectFailed ($l_host, $l_db, $l_ars, $l_ars_sev, $l_msg,
@l_errstr );
# &Logging (0, $A, "exception", $l_msg);
}
if ( $l_exe_ok != 1 ) {
$l_msg="$l_db Connect failure : $DBI::errstr";
# Check for errors to ignore, alert the Rest
@l_errstr = grep $DBI::errstr =~ m/$_/, keys
%G_IGNORE_ORACLE_ERRORS;
&ConnectFailed ($l_host, $l_db, $l_ars, $l_ars_sev, $l_msg,
@l_errstr );
}