← Back to team overview

maria-discuss team mailing list archive

Re: INSERT IGNORE (and other SQL commands) fail with: Deadlock found when trying to get lock;



> If memory serves me, the first timestamp, will be set
> to current universal time. Like db.table.last_changed

Ok, I replaced NOW() with a generated timestamp to avoid that NOW() deadlock.

sub mysql_now() {
        my($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,
        my($result)=sprintf("%4d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,
        return $result;


  my $mysqltimestamp = mysql_now();
  my $timestamph = $dbh->prepare("UPDATE user SET lastActive = ". $dbh-
>quote($mysqltimestamp) ." WHERE userid = ". $dbh->quote($user) ." and domain 
= ". $dbh->quote($domain));

Still in about 1 of 10 updates, this causes that wrenched Deadlock error, 
causing the email not being processed correctly and in the case the email is 
not for local but being forwarded, the email is not forwarded to the correct 

Dec 18 14:12:34 asterix mimedefang-multiplexor[8019]: NOQUEUE: Slave 0 stderr: 
DBD::mysql::st execute failed: Deadlock found when trying to get lock; try 
restarting transaction at /etc/mimedefang-filter.mx line 316.

Is there any known way to circumvent that Deadlock Problem?

Kind regards

Benoit Panizzon
I m p r o W a r e   A G    -    

Zurlindenstrasse 29             Tel  +41 61 826 93 07
CH-4133 Pratteln                Fax  +41 61 826 93 02
Schweiz                         Web  http://www.imp.ch

Follow ups