IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40878


Ignore:
Timestamp:
Aug 27, 2019, 12:07:38 PM (7 years ago)
Author:
tdeboer
Message:

Added safety to prevent deadlocks in label updates (prevents ipp117 and ipp113 instances deadlocking eachother)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/czartool/czartool/CzarDb.pm

    r40854 r40878  
    4040use czartool::StageMetrics;
    4141
     42
    4243###########################################################################
    4344#
     
    5455
    5556    return $self;
     57}
     58
     59###########################################################################
     60#
     61# Gets last czarpoll iteration time
     62#
     63###########################################################################
     64sub getPollDate {
     65    my ($self,$polldate) = @_;
     66
     67    my $query = $self->{_db}->prepare(<<SQL);
     68    SELECT timestamp FROM chip ORDER BY timestamp DESC LIMIT 1
     69SQL
     70
     71    $query->execute;
     72
     73    $polldate = $query->fetchrow_array();
     74
     75    return $polldate;
    5676}
    5777
     
    281301SQL
    282302
    283        $query->execute;
     303        #execute the query, but check for deadlocks
     304        my $db_res=0;
     305        while($db_res==0)
     306        {
     307            $db_res=1;
     308            my $result = eval{$query->execute;};
     309            unless($result) {
     310                 if(/DBD::mysql::st execute failed: Deadlock found when trying to get lock; try restarting transaction/){
     311                     $db_res=0;
     312                     sleep 3;
     313                 }
     314            }
     315        }
     316       
    284317    }
    285318}
Note: See TracChangeset for help on using the changeset viewer.