problems with forks and DBI appender

Help
2006-08-10
2013-06-04
  • Robert Jacobson

    Robert Jacobson - 2006-08-10

    My logger logs to screen, file, and mysql database.    My program forks children, and I was having a problem with the children sometimes hanging up.  I implemented a Syncer using Log::Log4perl::Appender::Synchronized on the database appender.  This seems to have resolved the hanging problem, but now when I SIGTERM my program (which calls a signal handler), I get the following error message:

    Use of uninitialized value in subroutine entry at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/Log/Log4perl.pm line 133 during global destruction.
            (in cleanup) Undefined subroutine &main:: called at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/Log/Log4perl.pm line 133 during global destruction.

    Just to be clear, the handler does seem to be called with no problems.  If it matters, I'm also using IPC::Semaphore in my main program (the handler removes the semaphore).

     
    • Robert Jacobson

      Robert Jacobson - 2006-08-10

      One additional fact:  the error messages go away if I remove all of the "print" calls to STDOUT.

       
    • Robert Jacobson

      Robert Jacobson - 2006-08-10

      The saga continues:

      I tested the Log4perl configuration file with some other perl programs I have, and I get some additional errors from IPC::Shareable:

      2006-222/13:52:24 ERROR> IPC/Shareable.pm Use of uninitialized value in substr at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/IPC/Shareable.pm line 542.

      Any ideas?

       
      • Mike Schilli

        Mike Schilli - 2006-08-10

        Can you send a snippet of code that reproduces the warning?

         
    • Mike Schilli

      Mike Schilli - 2006-08-10

      There's been a recent fix for this. Are you running Log-Log4perl-1.06?

      -- Mike
      Mike Schilli

       
    • Robert Jacobson

      Robert Jacobson - 2006-08-11

      I was running 1.04 -- I've upgraded to 1.06, and the Shareable.pm error messages seem to have gone away.  I'll check again tomorrow when I can actually reproduce the same conditions I had before.

       
    • Robert Jacobson

      Robert Jacobson - 2006-08-11

      Ok, back at work now.  The most of the errors I saw before do seem to have gone away.  However, I'm still getting the following error which I didn't notice before because of all the others:

      2006-223/12:24:48 ERROR> 5.8.7/Carp.pm 13298 Couldn't remove semaphore set 23789588: Identifier removed at source.pl line 0
      2006-223/12:24:48 ERROR> 5.8.7/Carp.pm 13300 Couldn't remove shared memory segment 23789588: Invalid argument at source.pl line 0

      Strangely, I only get this error if I run more than one instance of my program.  If I only run one copy, I never see the above error.  I'll send you the code offline.

       
    • Robert Jacobson

      Robert Jacobson - 2006-08-11

      Mike,

      Below is the program which generates the semaphore errors.  The errors only occur both of the following are true: 1) using the Synchronized appender, and 2) I define a SIGTERM handler.

      To reproduce, start at least 2 instances of the program below in the background, then kill all instances.  When I do so, I see these errors:

      Couldn't remove semaphore set 23789588: Identifier removed at source.pl line 0
      Couldn't remove shared memory segment 23789588: Invalid argument at source.pl line 0 

      Thanks for your help!

      ---------------------------------------------------
      #!/usr/bin/perl

      use strict;

      use Log::Log4perl qw(get_logger :levels);

      $SIG{'TERM'} = \&quit;
      sub quit;

      #Initialize logger
      Log::Log4perl->init(\q{
      log4perl.rootLogger                     = DEBUG, SyncScreen
      log4perl.appender.Screen                = Log::Log4perl::Appender::Screen
      log4perl.appender.Screen.layout         = Log::Log4perl::Layout::SimpleLayout
      log4perl.appender.SyncScreen            = Log::Log4perl::Appender::Synchronized
      log4perl.appender.SyncScreen.appender   = Screen
      });
      my $logger = get_logger();
      $logger->info("Starting.....");

      while (1)
      {
              sleep (30);
      }

      sub quit
      {
              exit ();
      }

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks