[Mimedefang] awk.lock errors

Paul Murphy pmurphy at ionixpharma.com
Tue Sep 14 10:48:50 EDT 2004


Richard,

Enable debugging of SpamAssassin to see the full details of lock creation and
management - in SpamAssassin.pm (in /usr/share/perl5/Mail on my system), at line
231 (version 2.63) change the line to  
		$DEBUG->{enabled} = 1; 
And then sit back and watch your log files grow very quickly.

What I suspect is happening is that a race condition is developing between
multiple MD slaves, where one slave is using the lock file, a second slave
checks for its existence, finds it but decides that it is too old, and then
tries to unlink it to break the lock, but between checking for it and unlinking,
some other slave has done the same, and deleted the file.  

The first error you get is due to stat() failing on a non-existent file
(therefore $stat[3] is undefined):

    # link _may_ return false even if the link _is_ created
    @stat = stat($lock_tmp);           
    if ($stat[3] > 1) {		# NOTE A
      dbg("lock: $$ link to $lock_file: stat ok");
      $is_locked = 1;
      last;           
    }
NOTE A: stat() returns a null list if the file doesn't exist, so in this case
$stat[3] is not defined.

The second is due to a coding error in the SpamAssassin.pm module:

    # check age of lockfile ctime
    my $now = ($#stat < 11 ? undef : $stat[10]);		# NOTE B
    @stat = stat($lock_file);  
    my $lock_age = ($#stat < 11 ? undef : $stat[10]); 	# NOTE B
    if (!defined($lock_age) || ($now - $lock_age) > LOCK_MAX_AGE) {
      # we got a stale lock, break it
      dbg("lock: $$ breaking stale $lock_file: age=" .
          (defined $lock_age ? $lock_age : "undef") . " now=$now");	# NOTE C
      unlink ($lock_file) || warn "lock: $$ unlink of lock file $lock_file faile
d: $!\n";
    }
NOTE A: since $stat is undefined, these values are undefined
NOTE B: there is a check that $lock_age is defined, but not that $now is
defined.

The amount of time between the stat() and the unlink() is very small but on a
heavily loaded system with many slaves, I wouldn't be surprised to see it cause
issues.

Best Wishes,

Paul.
__________________________________________________
Paul Murphy
Head of Informatics
Ionix Pharmaceuticals Ltd
418 Science Park, Cambridge, CB4 0PA

Tel. 01223 433741
Fax. 01223 433788


_______________________________________________________________________
DISCLAIMER:
This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to which they
are addressed.  If you have received this email in error please contact
the sender or the Ionix IT Helpdesk on +44 (0) 1223 433741
_______________________________________________________________________ 



More information about the MIMEDefang mailing list