Commit 8f00293e authored by Leo Gordon's avatar Leo Gordon
Browse files

try not to shock the Q::register_worker_death() code with inexistent W->analysis_id

parent 24fdc833
...@@ -279,41 +279,43 @@ sub specialize_new_worker { ...@@ -279,41 +279,43 @@ sub specialize_new_worker {
sub register_worker_death { sub register_worker_death {
my ($self, $worker) = @_; my ($self, $worker) = @_;
return unless($worker); return unless($worker);
my $cod = $worker->cause_of_death() || 'UNKNOWN'; # make sure we do not attempt to insert a void my $cod = $worker->cause_of_death() || 'UNKNOWN'; # make sure we do not attempt to insert a void
my $sql = "UPDATE worker SET died=CURRENT_TIMESTAMP, last_check_in=CURRENT_TIMESTAMP"; my $sql = qq{UPDATE worker SET died=CURRENT_TIMESTAMP
$sql .= " ,status='DEAD'"; ,last_check_in=CURRENT_TIMESTAMP
$sql .= " ,work_done='" . $worker->work_done . "'"; ,status='DEAD'
$sql .= " ,cause_of_death='$cod'"; ,work_done='}. $worker->work_done . qq{'
$sql .= " WHERE worker_id='" . $worker->dbID ."'"; ,cause_of_death='$cod'
WHERE worker_id='}. $worker->dbID . qq{'};
$self->dbc->do( $sql );
$self->dbc->do( $sql ); if(my $analysis_id = $worker->analysis_id) {
my $analysis_stats_adaptor = $self->db->get_AnalysisStatsAdaptor;
unless( $self->db->hive_use_triggers() ) { unless( $self->db->hive_use_triggers() ) {
$worker->analysis->stats->adaptor->decrease_running_workers($worker->analysis_id); $analysis_stats_adaptor->decrease_running_workers($worker->analysis_id);
} }
if($cod eq 'NO_WORK') { if($cod eq 'NO_WORK') {
$self->db->get_AnalysisStatsAdaptor->update_status($worker->analysis->dbID, 'ALL_CLAIMED'); $analysis_stats_adaptor->update_status($worker->analysis_id, 'ALL_CLAIMED');
} } elsif($cod eq 'UNKNOWN'
if($cod eq 'UNKNOWN' or $cod eq 'MEMLIMIT'
or $cod eq 'MEMLIMIT' or $cod eq 'RUNLIMIT'
or $cod eq 'RUNLIMIT' or $cod eq 'KILLED_BY_USER') {
or $cod eq 'KILLED_BY_USER') { $self->db->get_AnalysisJobAdaptor->release_undone_jobs_from_worker($worker);
$self->db->get_AnalysisJobAdaptor->release_undone_jobs_from_worker($worker); }
}
# re-sync the analysis_stats when a worker dies as part of dynamic sync system
if($self->safe_synchronize_AnalysisStats($worker->analysis->stats)->status ne 'DONE') {
# since I'm dying I should make sure there is someone to take my place after I'm gone ...
# above synch still sees me as a 'living worker' so I need to compensate for that
$self->db->get_AnalysisStatsAdaptor->increase_required_workers($worker->analysis->dbID);
}
# re-sync the analysis_stats when a worker dies as part of dynamic sync system
if($self->safe_synchronize_AnalysisStats($worker->analysis->stats)->status ne 'DONE') {
# since I'm dying I should make sure there is someone to take my place after I'm gone ...
# above synch still sees me as a 'living worker' so I need to compensate for that
$analysis_stats_adaptor->increase_required_workers($worker->analysis_id);
}
}
} }
......
...@@ -213,7 +213,7 @@ sub main { ...@@ -213,7 +213,7 @@ sub main {
if( $meadow->check_worker_is_alive_and_mine ) { if( $meadow->check_worker_is_alive_and_mine ) {
printf("Killing worker: %10d %35s %15s %20s(%d) : ", printf("Killing worker: %10d %35s %15s %20s(%d) : ",
$kill_worker->dbID, $kill_worker->host, $kill_worker->process_id, $kill_worker->dbID, $kill_worker->host, $kill_worker->process_id,
$kill_worker->analysis->logic_name, $kill_worker->analysis->dbID); $kill_worker->analysis->logic_name, $kill_worker->analysis_id);
$meadow->kill_worker($kill_worker); $meadow->kill_worker($kill_worker);
$kill_worker->cause_of_death('KILLED_BY_USER'); $kill_worker->cause_of_death('KILLED_BY_USER');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment