From aadc55d3cf55ae4e9a37ad5ce59cc32fa77bfb98 Mon Sep 17 00:00:00 2001 From: Jessica Severin <jessica@ebi.ac.uk> Date: Mon, 13 Jun 2005 11:14:42 +0000 Subject: [PATCH] changed behaviour so that claiming of jobs preferentially picks jobs that have not been run before (< retry_count) --- .../EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm index 29443e5cf..608f95801 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm @@ -450,18 +450,23 @@ sub claim_jobs_for_worker { my $claim = $ug->to_string( $uuid ); #print("claiming jobs for hive_id=", $worker->hive_id, " with uuid $claim\n"); - my $sql = "UPDATE analysis_job SET job_claim='$claim'". - " , hive_id='". $worker->hive_id ."'". - " , status='CLAIMED'". - " WHERE job_claim='' and status='READY'". - " AND analysis_id='" .$worker->analysis->dbID. "'". - " LIMIT " . $worker->batch_size; - - #print("$sql\n"); - my $sth = $self->prepare($sql); - $sth->execute(); - $sth->finish; - + my $sql_base = "UPDATE analysis_job SET job_claim='$claim'". + " , hive_id='". $worker->hive_id ."'". + " , status='CLAIMED'". + " WHERE job_claim='' and status='READY'". + " AND analysis_id='" .$worker->analysis->dbID. "'"; + + my $sql_virgin = $sql_base . + " AND retry_count=0". + " LIMIT " . $worker->batch_size; + + my $sql_any = $sql_base . + " LIMIT " . $worker->batch_size; + + my $claim_count = $self->dbc->do($sql_virgin); + if($claim_count == 0) { + $claim_count = $self->dbc->do($sql_any); + } return $claim; } -- GitLab