Subject: | Connection failure still fatal even with : no_connect_failures => 1 |
The problem occurs if no_connect_failures is set to 1 and the initial
connect fails. When EasyDBI eventually succeeds in connecting the next
post(...) to EasyDBI will fail.
The following output is from the attached script.
$ perl EasyDBI.pl
DBerr at 1213292004
DBerr at 1213292006
DBerr at 1213292008
DBconn at 1213292010
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/POE/Component/EasyDBI.pm line 596.
I just created a user (auser) with a bad password. Once EasyDBI was
running I changed to the password in the DB to the one expected by the
script (apass). The connection succeeded, but the EasyDBI object was
unusable.
The attached script uses POE::Component::EasyDBI->new(...), but create
and spawn had the same results.
Tested on Ubuntu Linux. perl 5.8.8
Subject: | EasyDBI.pl |
#!perl -w
use strict;
use warnings;
use POE qw( Component::EasyDBI );
POE::Session->create(inline_states => { _start => \&start,
stop => sub {},
DBconn => \&DBconn,
DBerr => sub {
print "DBerr at ", time(), "\n";
$_[HEAP]->{DBerr}++;
},
DBresults => sub {
print "DBresults at ", time(), "\n";
}
},
);
$poe_kernel->run;
sub DBconn {
print "DBconn at ", time(), "\n";
$_[KERNEL]->post( 'EasyDBI',
arrayhash => {
sql => 'SELECT unix_timestamp()',
event => 'DBresults',
}
);
}
sub start {
$_[KERNEL]->alias_set('mySession');
my $dsn = "dbi:mysql:database=test;host=localhost;port=3306";
my ($user, $pass) = ( 'auser', 'apass' );
$_[HEAP]->{EasyDBI} =
POE::Component::EasyDBI->new( alias => 'EasyDBI',
dsn => $dsn,
username => $user,
password => $pass,
no_connect_failures => 1,
connect_error => ['mySession', 'DBerr'],
connected => ['mySession', 'DBconn']
);
}