Commit 26f27a0f authored by Leo Gordon's avatar Leo Gordon
Browse files

let jobs decide whether it makes any sense to restart them or not

parent a76de6b6
......@@ -139,6 +139,8 @@ sub stderr_file {
return $self->{'_stderr_file'};
}
##-----------------[indicators to the Worker]--------------------------------
sub lethal_for_worker { # Job should set this to 1 prior to dying (or before running code that might cause death - such as RunnableDB's compilation)
# if it believes that the state of things will not allow the Worker to continue normally.
# The Worker will check the flag and commit suicide if it is set to true.
......@@ -147,6 +149,18 @@ sub lethal_for_worker { # Job should set this to 1 prior to dying (or before
return $self->{'_lethal_for_worker'};
}
sub transient_error { # Job should set this to 1 prior to dying (or before running code that might cause death)
# if it believes that it makes sense to retry the same job without any changes.
# It may also set it to 0 prior to dying (or before running code that might cause death)
# if it believes that there is no point in re-trying (say, if the parameters are wrong).
# The Worker will check the flag and make necessary adjustments to the database state.
my $self = shift;
$self->{'_transient_error'} = shift if(@_);
return $self->{'_transient_error'};
}
##-----------------[/indicators to the Worker]-------------------------------
sub print_job {
my $self = shift;
my $logic_name = $self->adaptor()
......
......@@ -515,7 +515,11 @@ sub run
my $job_status_when_died = $job->status();
warn "Job with id=$job_id died in status '$job_status_when_died' for the following reason: $error_msg\n";
$self->db()->get_JobErrorAdaptor()->register_error($job_id, $error_msg);
$job->update_status('FAILED');
if($job->transient_error) {
$job->adaptor->reset_dead_job_by_dbID($job_id);
} else {
$job->update_status('FAILED');
}
if($job->lethal_for_worker) { # either a compilation error or other job-sanctioned contamination
warn "Job's error has contaminated the Worker, so the Worker will now die\n";
......
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