Commit ddbb2ad2 authored by Jessica Severin's avatar Jessica Severin
Browse files

fixed job reset/claim logic and API. Works better for debugging.

parent 1e5ff11e
......@@ -227,38 +227,47 @@ sub worker_grab_jobs {
return $jobs;
}
=head2 grab_job_by_dbID
=head2 reset_and_fetch_job_by_dbID
Arg [1]: int $analysis_job_id
Example:
my $job = $queen->grab_job_by_dbID($analysis_job_id);
my $job = $queen->reset_and_fetch_job_by_dbID($analysis_job_id);
Description:
For the specified analysis_job_id it will fetch just that job,
reclaim it and return it. Specifying a specific job bypasses
the safety checks, thus multiple workers could be running the
reset it completely as if it has never run, and return it.
Specifying a specific job bypasses the safety checks,
thus multiple workers could be running the
same job simultaneously (use only for debugging).
Returntype :
Bio::EnsEMBL::Hive::AnalysisJob objects
Bio::EnsEMBL::Hive::AnalysisJob object
Exceptions :
Caller :
Caller : beekeepers, runWorker.pl scripts
=cut
sub grab_job_by_dbID {
my $self = shift;
sub reset_and_fetch_job_by_dbID {
my $self = shift;
my $analysis_job_id = shift;
return undef unless($analysis_job_id);
my $jobDBA = $self->db->get_AnalysisJobAdaptor;
printf("fetching job for id ", $analysis_job_id, "\n");
my $job = $jobDBA->fetch_by_dbID($analysis_job_id);
return undef unless($job);
$jobDBA->reset_job_by_dbID($analysis_job_id);
my $job = $jobDBA->fetch_by_dbID($analysis_job_id);
my $stats = $self->db->get_AnalysisStatsAdaptor->fetch_by_analysis_id($job->analysis_id);
$self->synchronize_AnalysisStats($stats);
$job->hive_id(0);
$jobDBA->reclaim_job($job);
$self->db->get_AnalysisStatsAdaptor->update_status($job->analysis_id, 'LOADING');
return $job;
}
sub worker_reclaim_job {
my $self = shift;
my $worker = shift;
my $job = shift;
return undef unless($job and $worker);
$job->hive_id($worker->hive_id);
$self->db->get_AnalysisJobAdaptor->reclaim_job($job);
return $job;
}
......@@ -303,6 +312,12 @@ sub fetch_overdue_workers {
return $self->_generic_fetch($constraint);
}
sub fetch_failed_workers {
my $self = shift;
my $constraint = "h.cause_of_death='FATALITY' ";
return $self->_generic_fetch($constraint);
}
=head2 synchronize_hive
......
......@@ -372,7 +372,7 @@ sub run
my $jobs = [];
if($specific_job) {
$specific_job->hive_id($self->hive_id);
$self->queen->worker_reclaim_job($self,$specific_job);
push @$jobs, $specific_job;
} else {
$jobs = $self->queen->worker_grab_jobs($self);
......
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