Commit d9f1b05b authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

bugfix: the claimed batch was not released

The problem was when a worker is contaminated and has to die: remainings jobs
of the batch were not released.
We now have an explicit list of all the cause_of_death that could happen through
a batch, and for which we should free the jobs
parent 3a7601af
......@@ -295,15 +295,16 @@ sub register_worker_death {
my $worker_died = $worker->died;
my $current_role = $worker->current_role;
my $release_undone_jobs = 0;
unless( $current_role ) {
$worker->current_role( $current_role = $self->db->get_RoleAdaptor->fetch_last_unfinished_by_worker_id( $worker_id ) );
# $current_role can be undef if the cause_of_death is NO_ROLE
$release_undone_jobs = 1 if $current_role;
if( $current_role and !$current_role->when_finished() ) {
# List of cause_of_death:
# only happen before or after a batch: 'NO_ROLE','NO_WORK','JOB_LIMIT','HIVE_OVERLOAD','LIFESPAN', 'SEE_MSG'
# can happen whilst the worker is running a batch: 'CONTAMINATED','RELOCATED','KILLED_BY_USER','MEMLIMIT','RUNLIMIT','UNKNOWN'
my $release_undone_jobs = ($cause_of_death =~ /^(CONTAMINATED|RELOCATED|KILLED_BY_USER|MEMLIMIT|RUNLIMIT|UNKNOWN)$/);
$current_role->worker($worker); # So that release_undone_jobs_from_role() has the correct cause_of_death and work_done
$current_role->when_finished( $worker_died );
$self->db->get_RoleAdaptor->finalize_role( $current_role, $release_undone_jobs );
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