mschilli / log4perl

Log4j Implementation For Perl
http://log4perl.com
Other
116 stars 66 forks source link

Synchronized Appender locking up system with semaphores #88

Open marcelser opened 6 years ago

marcelser commented 6 years ago

Hi,

We have a system which forks children and we found out that sometimes log4perl messages are interleaved (especially for long messages) so we added the "Synchronized" Appenders the the logfiles and created a different semaphore (4 char long .key) for each and every appender file based logger.

At first tests it looked perfectly ok, but once we put the code on our QA testing system it started to fail miserable, we had strange lockups all over the place and as I have not really found out how that semaphores stuff is working I also feel unable to fix this issue. But I think it seems somehow the locks don't get released but I don't even know how to trace this.

BTW: We are using Log4perl 1.46 provided by centos7.

marcelser commented 6 years ago

ok, we found out what's the problem. If any log4perl module outputs something to stderr/stdout and you're using the recipe to catch all output from stderr & stdout and redirect to log4perl you run into a semaphore deadlock as you're entering the 'log' subroutine again in a recursion and it waits indefinitly.

For the moment I have monkey patched the 'log' method of the Appender to run a counter and only lock/umlock the semaphore if counter == 0, also error handling is not done properly here, if the log method dies you're also left with a locked semaphore and system is in deadlock mode.

Laz80UK commented 5 years ago

Hi,

I had the same issue. The semaphore errors were showing up in the Centos 7 syslogs and my software stopped processing all together. Had to fall back to the following configuration:

log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.autoflush = 1 log4perl.appender.Logfile.mode = append log4perl.appender.Logfile.syswrite = 1

(i.e. not using Log::Log4perl::Appender::Synchronized)

mohawk2 commented 3 years ago

Thanks for the report. Could one of you please put here a code snippet that demonstrates the problem, or even better put it in a .t for easy adding?