Ticket #279 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[PATCH] process-quarantine.pl loops forever when the -sub script dies w/ non-0 exit

Reported by: jnorell Owned by: rjl
Priority: normal Milestone: 1.0.1
Component: Perl scripts Version: 1.0.0
Severity: normal Keywords:
Cc:

Description

I inadvertently updated to DBD-mysql version 3 and had the problem with process-quarantine-sub.pl dieing with the error:

Out of memory! Out of memory! Callback called exit.

and an exit status of 12. Downgrading to a version < 3.0 will fix that, but combined with the design of process-quarantine.pl, it has the effect of almost completely shutting down the mail system. The process-quarantine-sub.pl script returns the number of items processed through the exit() value, and the parent loops until it exit(0)'s. With the above problem, I keep getting an exit value of 12, so the parent loops forever, hogging cpu, memory and database connections.

This is a bit of a hack/ugly, but not being a perl guru, it wasn't

terribly obvious how to get both stdout and the exit value from a child process, so this is what I came up with. I tested it works when the -sub script fails; specifically it does:

# ./process-quarantine.pl Out of memory! Out of memory! Callback called exit. subroutine died with error status: 12 at ./process-quarantine.pl line 182, <CL> line 1. #

And works with a downgraded DBD-mysql, too:

# ./process-quarantine.pl --learn Learned mail item 3247 as SPAM Processing completed: 0 items processed in 1 runs. #

Lightly tested, but working so far.

--- process-quarantine.pl.orig 2006-03-08 15:17:54.000000000 -0700 +++ process-quarantine.pl 2006-03-09 10:41:05.000000000 -0700 @@ -164,13 +164,28 @@

push(@cl_array, "--ham-only") if ($hamonly); # process ham only push(@cl_array, "--debug") if ($debug); # turn on debugging mode push(@cl_array, "--quiet") if ($quiet); # turn on quiet mode

+push(@cl_array, " /bin/echo \"DIED: \$?\""); # hacked exit status reporter + +my $cl_command = join(' ', @cl_array);

# Call the subroutine until there are no items left to process my $total_items_processed = 0; my $total_processing_runs = 0; my $items_processed = -1; while ($items_processed != 0) {

- $items_processed = system(@cl_array) / 256; + $items_processed = 0;

+ open(CL, "$cl_command |") die "can't run subroutine: $!\n"; + while (chomp(my $clout = <CL>)) { + if ($clout =~ m/DIED: (\d)+/) { + $clout =~ s/DIED: //; + die "subroutine died with error status $clout"; + } elsif ($clout =~ m/(\d)+/) { + $items_processed .= $clout; + } else { + print "$clout\n"; + } + } + close(CL);

$total_items_processed += $items_processed; $total_processing_runs++; if ($debug) {

--- process-quarantine-sub.pl.orig 2006-03-08 15:18:00.000000000 -0700 +++ process-quarantine-sub.pl 2006-03-08 16:23:59.000000000 -0700 @@ -111,7 +111,7 @@

{

my ($msg) = @_;

- print $msg . "\n"; + print STDERR $msg . "\n";

exit 0;

}

@@ -558,5 +558,6 @@

# Disconnect from the database $dbh->disconnect;

-# We're done, return the total number of items processed. -exit ($spamcount + $hamcount); +# We're done, print the total number of items processed and return. +print ($spamcount + $hamcount); +exit(0);

Attachments

process-quarantine.patch (1.7 kB) - added by jnorell 4 years ago.

Change History

Changed 4 years ago by jnorell

Changed 4 years ago by rjl

  • version set to 1.0.0
  • milestone set to 1.0.1

Changed 4 years ago by rjl

  • status changed from new to closed
  • resolution set to fixed

Fixed in Changeset 965. Return (i.e. exit()) values from the worker script are limited to the 0-255 range, so an upper bound of 127 is imposed on the "--limit" argument, so that 127 spam + 127 non-spam = 254 at most, and 255 is reserved as an error code. The master script will halt immediately if the error code is returned by the worker script.

Changed 4 years ago by rjl

  • summary changed from process-quarantine.pl loops forever when the -sub script dies w/ non-0 exit to [PATCH] process-quarantine.pl loops forever when the -sub script dies w/ non-0 exit
Note: See TracTickets for help on using tickets.