Commit 85880029 authored by Leo Gordon's avatar Leo Gordon
Browse files

Back to num_required_workers' meaning "how many extra workers we need to add...

Back to num_required_workers' meaning "how many extra workers we need to add to this analysis"; fixing a scheduling bug/oversensitivity to manual change of batch_size
parent be41de02
......@@ -134,9 +134,7 @@ sub num_running_workers {
return $self->{'_num_running_workers'};
}
# NB: the meaning of this field changes from "how many workers we need to add" to "how many workers we actually need"
sub num_required_workers {
sub num_required_workers { # NB: the meaning of this field is, again, "how many extra workers we need to add"
my $self = shift;
$self->{'_num_required_workers'} = shift if(@_);
return $self->{'_num_required_workers'};
......
......@@ -90,7 +90,7 @@ sub fetch_all_by_suitability_rc_id_meadow_type {
# the ones that clearly have work to do:
#
my $primary_results = $self->_generic_fetch(
"ast.num_running_workers<ast.num_required_workers AND ast.status in ('READY', 'WORKING')" ,
"ast.num_required_workers>0 AND ast.status in ('READY', 'WORKING')" ,
$join ,
'ORDER BY a.priority DESC, ' . ( ($self->dbc->driver eq 'sqlite') ? 'RANDOM()' : 'RAND()' ),
);
......
......@@ -250,7 +250,7 @@ sub specialize_new_worker {
if($stats->status eq 'BLOCKED') {
die "Analysis is BLOCKED, can't specialize a worker";
}
if($stats->num_running_workers >= $stats->num_required_workers) {
if($stats->num_required_workers <= 0) {
die "Analysis doesn't require extra workers at the moment";
}
if($stats->status eq 'DONE') {
......@@ -621,8 +621,7 @@ sub synchronize_AnalysisStats {
my $scheduling_allowed = ( !defined( $analysisStats->hive_capacity ) or $analysisStats->hive_capacity )
&& ( !defined( $analysis->analysis_capacity ) or $analysis->analysis_capacity );
my $required_workers = $scheduling_allowed
&& POSIX::ceil( ($analysisStats->ready_job_count() + $analysisStats->inprogress_job_count())
/ $analysisStats->get_or_estimate_batch_size() );
&& POSIX::ceil( $analysisStats->ready_job_count() / $analysisStats->get_or_estimate_batch_size() );
$analysisStats->num_required_workers( $required_workers );
......@@ -833,7 +832,7 @@ sub suggest_analysis_to_specialize_by_rc_id_meadow_type {
#synchronize and double check that it can be run:
$self->safe_synchronize_AnalysisStats($stats);
return $stats if( ($stats->status ne 'BLOCKED') and ($stats->status ne 'SYNCHING') and ($stats->num_running_workers < $stats->num_required_workers) );
return $stats if( ($stats->status ne 'BLOCKED') and ($stats->status ne 'SYNCHING') and ($stats->num_required_workers > 0) );
}
return undef;
......
......@@ -119,7 +119,7 @@ sub schedule_workers {
next if($analysis_stats->status eq 'BLOCKED');
# getting the initial worker requirement for this analysis (may be stale if not sync'ed recently)
my $extra_workers_this_analysis = $analysis_stats->num_required_workers - $analysis_stats->num_running_workers;
my $extra_workers_this_analysis = $analysis_stats->num_required_workers;
# if this analysis doesn't require any extra workers - just skip it:
next if ($extra_workers_this_analysis <= 0);
......
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