diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm index a8c78f01a317d0c3723d791aecaa612c2c4d6057..c591b544746230768cf8af7a78d273a4d8bdeca1 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/DBAdaptor.pm @@ -154,7 +154,7 @@ sub hive_use_triggers { # getter only, not setter unless( defined($self->{'_hive_use_triggers'}) ) { my $hive_use_triggers = $self->get_MetaAdaptor->get_value_by_key( 'hive_use_triggers' ); - $self->{'_hive_use_triggers'} = $hive_use_triggers || 0; + $self->{'_hive_use_triggers'} = $hive_use_triggers // 0; } return $self->{'_hive_use_triggers'}; } @@ -165,12 +165,23 @@ sub hive_use_param_stack { # getter only, not setter unless( defined($self->{'_hive_use_param_stack'}) ) { my $hive_use_param_stack = $self->get_MetaAdaptor->get_value_by_key( 'hive_use_param_stack' ); - $self->{'_hive_use_param_stack'} = $hive_use_param_stack || 0; + $self->{'_hive_use_param_stack'} = $hive_use_param_stack // 0; } return $self->{'_hive_use_param_stack'}; } +sub hive_auto_rebalance_semaphores { # getter only, not setter + my $self = shift @_; + + unless( defined($self->{'_hive_auto_rebalance_semaphores'}) ) { + my $hive_auto_rebalance_semaphores = $self->get_MetaAdaptor->get_value_by_key( 'hive_auto_rebalance_semaphores' ); + $self->{'_hive_auto_rebalance_semaphores'} = $hive_auto_rebalance_semaphores // 0; + } + return $self->{'_hive_auto_rebalance_semaphores'}; +} + + our %adaptor_type_2_package_name = ( 'Accumulator' => 'Bio::EnsEMBL::Hive::DBSQL::AccumulatorAdaptor', 'Analysis' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor', diff --git a/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm b/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm index 167840d447486ce5349845a781966418499673fe..18d0e027eb012cc3e57d737c527d57ad656c0af9 100644 --- a/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm +++ b/modules/Bio/EnsEMBL/Hive/PipeConfig/HiveGeneric_conf.pm @@ -104,10 +104,11 @@ sub default_options { 'dbowner' => $ENV{'EHIVE_USER'} || $ENV{'USER'} || $self->o('dbowner'), # although it is very unlikely $ENV{USER} is not set 'pipeline_name' => $self->pipeline_name(), - 'hive_use_triggers' => 0, # there have been a few cases of big pipelines misbehaving with triggers on, let's keep the default off. - 'hive_use_param_stack' => 0, # do not reconstruct the calling stack of parameters by default (yet) - 'hive_force_init' => 0, # setting it to 1 will drop the database prior to creation (use with care!) - 'hive_no_init' => 0, # setting it to 1 will skip pipeline_create_commands (useful for topping up) + 'hive_use_triggers' => 0, # there have been a few cases of big pipelines misbehaving with triggers on, let's keep the default off. + 'hive_use_param_stack' => 0, # do not reconstruct the calling stack of parameters by default (yet) + 'hive_auto_rebalance_semaphores' => 0, # do not attempt to rebalance semaphores periodically by default + 'hive_force_init' => 0, # setting it to 1 will drop the database prior to creation (use with care!) + 'hive_no_init' => 0, # setting it to 1 will skip pipeline_create_commands (useful for topping up) 'pipeline_db' => { -driver => $self->o('hive_driver'), @@ -226,9 +227,10 @@ sub hive_meta_table { my ($self) = @_; return { - 'hive_sql_schema_version' => Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor->get_code_sql_schema_version(), - 'hive_pipeline_name' => $self->o('pipeline_name'), - 'hive_use_param_stack' => $self->o('hive_use_param_stack'), + 'hive_sql_schema_version' => Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor->get_code_sql_schema_version(), + 'hive_pipeline_name' => $self->o('pipeline_name'), + 'hive_use_param_stack' => $self->o('hive_use_param_stack'), + 'hive_auto_rebalance_semaphores' => $self->o('hive_auto_rebalance_semaphores'), }; } diff --git a/modules/Bio/EnsEMBL/Hive/Scheduler.pm b/modules/Bio/EnsEMBL/Hive/Scheduler.pm index a03fbab9fde468b938bd0c8bfc623ff66afd6c50..58639776688f5093ead9ef840b1572613b83ff95 100644 --- a/modules/Bio/EnsEMBL/Hive/Scheduler.pm +++ b/modules/Bio/EnsEMBL/Hive/Scheduler.pm @@ -66,8 +66,14 @@ sub schedule_workers_resync_if_necessary { print "Scheduler: mismatch between DB's active Roles and Valley's running Workers detected, checking for dead workers...\n"; $queen->check_for_dead_workers($valley, 1); } - print "Scheduler: re-balancing of semaphore_counts...\n"; - $queen->db->get_AnalysisJobAdaptor->balance_semaphores($filter_analysis && $filter_analysis->dbID); + + if($queen->db->hive_auto_rebalance_semaphores) { # make sure rebalancing only ever happens for the pipelines that asked for it + print "Scheduler: re-balancing of semaphore_counts...\n"; + $queen->db->get_AnalysisJobAdaptor->balance_semaphores($filter_analysis && $filter_analysis->dbID); + } else { + print "Scheduler: automatic re-balancing of semaphore_counts is off by default. If you think your pipeline might benefit from it, set hive_auto_rebalance_semaphores => 1 in the PipeConfig's hive_meta_table.\n"; + } + print "Scheduler: re-synchronizing the Hive...\n"; $queen->synchronize_hive($filter_analysis);