While trying to debug a problem when logging to a MySQL database with Log4perl::Appender::DBI.
It would just fail saying :
Uncaught exception from user code:
Log4perl: DBI appender failed to reconnect to database after 3 attempts at ./CSV_gen_sync.pl line 385
at /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Appender/DBI.pm line 145
Log::Log4perl::Appender::DBI::query_execute('Log::Log4perl::Appender::DBI=HASH(0x9ea8bd4)', 'DBI::st=HASH(0xa041400)', 'INFO', '2007/08/01 12:19:57', 'publish_files returned an exit_status of 0') called at /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Appender/DBI.pm line 112
Log::Log4perl::Appender::DBI::log('Log::Log4perl::Appender::DBI=HASH(0x9ea8bd4)', 'level', 1, 'name', 'DB', 'message', 'ARRAY(0xa03f93c)', 'log4p_category', 'LogFile', ...) called at /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Appender.pm line 189
Log::Log4perl::Appender::log('Log::Log4perl::Appender=HASH(0x9e96f20)', 'HASH(0xa03f9cc)', 'LogFile', 'INFO') called at (eval 52) line 41
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0x9ad313c)', 'publish_files returned an exit_status of 0') called at /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Logger.pm line 771
Log::Log4perl::Logger::__ANON__('Log::Log4perl::Logger=HASH(0x9ad313c)', 'publish_files returned an exit_status of 0') called at ./CSV_gen_sync.pl line 385
msoffen:msoffen:/usr0/html_files_www/smd/operations_reports/scripts
I added an explicit print of the $DBI::errstr to the loop and got this:
DBI::errstr: Duplicate entry 'INFO-2007/08/01 12:19:57' for key 1
It appears that it doesn't handl that as a "real" DB error and just gives a generic failure to connect when it is actually connecting just fine and having a problem storing the record.