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

cause_of_death="" no longer used for decision making, cause_of_death IS NULL...

cause_of_death="" no longer used for decision making, cause_of_death IS NULL by default and FATALITY renamed UNKNOWN for clarity
parent 6f85948d
...@@ -283,7 +283,7 @@ sub register_worker_death { ...@@ -283,7 +283,7 @@ sub register_worker_death {
return unless($worker); return unless($worker);
my $cod = $worker->cause_of_death(); my $cod = $worker->cause_of_death() || 'UNKNOWN'; # make sure we do not attempt to insert a void
my $sql = "UPDATE worker SET died=CURRENT_TIMESTAMP, last_check_in=CURRENT_TIMESTAMP"; my $sql = "UPDATE worker SET died=CURRENT_TIMESTAMP, last_check_in=CURRENT_TIMESTAMP";
$sql .= " ,status='DEAD'"; $sql .= " ,status='DEAD'";
...@@ -300,7 +300,7 @@ sub register_worker_death { ...@@ -300,7 +300,7 @@ sub register_worker_death {
if($cod eq 'NO_WORK') { if($cod eq 'NO_WORK') {
$self->db->get_AnalysisStatsAdaptor->update_status($worker->analysis->dbID, 'ALL_CLAIMED'); $self->db->get_AnalysisStatsAdaptor->update_status($worker->analysis->dbID, 'ALL_CLAIMED');
} }
if($cod eq 'FATALITY' if($cod eq 'UNKNOWN'
or $cod eq 'MEMLIMIT' or $cod eq 'MEMLIMIT'
or $cod eq 'RUNLIMIT' or $cod eq 'RUNLIMIT'
or $cod eq 'KILLED_BY_USER') { or $cod eq 'KILLED_BY_USER') {
...@@ -372,7 +372,7 @@ sub check_for_dead_workers { # scans the whole Valley for lost Workers (but i ...@@ -372,7 +372,7 @@ sub check_for_dead_workers { # scans the whole Valley for lost Workers (but i
warn "GarbageCollector:\tReleasing the jobs\n"; warn "GarbageCollector:\tReleasing the jobs\n";
while(my ($process_id, $worker) = each %$pid_to_lost_worker) { while(my ($process_id, $worker) = each %$pid_to_lost_worker) {
$worker->cause_of_death( $wpid_to_cod->{$process_id} || 'FATALITY'); $worker->cause_of_death( $wpid_to_cod->{$process_id} || 'UNKNOWN');
$self->register_worker_death($worker); $self->register_worker_death($worker);
} }
} }
...@@ -449,7 +449,7 @@ sub fetch_overdue_workers { ...@@ -449,7 +449,7 @@ sub fetch_overdue_workers {
$overdue_secs = 3600 unless(defined($overdue_secs)); $overdue_secs = 3600 unless(defined($overdue_secs));
my $constraint = "cause_of_death='' AND ". my $constraint = "status!='DEAD' AND ".
( ($self->dbc->driver eq 'sqlite') ( ($self->dbc->driver eq 'sqlite')
? "(strftime('%s','now')-strftime('%s',last_check_in))>$overdue_secs" ? "(strftime('%s','now')-strftime('%s',last_check_in))>$overdue_secs"
: "(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(last_check_in))>$overdue_secs"); : "(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(last_check_in))>$overdue_secs");
...@@ -676,8 +676,10 @@ sub get_hive_current_load { ...@@ -676,8 +676,10 @@ sub get_hive_current_load {
my $self = shift; my $self = shift;
my $sql = qq{ my $sql = qq{
SELECT sum(1/hive_capacity) SELECT sum(1/hive_capacity)
FROM worker JOIN analysis_stats USING(analysis_id) FROM worker w
WHERE cause_of_death ='' AND hive_capacity>0 JOIN analysis_stats USING(analysis_id)
WHERE w.status!='DEAD'
AND hive_capacity>0
}; };
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
$sth->execute(); $sth->execute();
...@@ -690,8 +692,11 @@ sub get_hive_current_load { ...@@ -690,8 +692,11 @@ sub get_hive_current_load {
sub count_running_workers { sub count_running_workers {
my ($self, $analysis_id) = @_; my ($self, $analysis_id) = @_;
my $sql = "SELECT count(*) FROM worker WHERE cause_of_death =''" my $sql = qq{
. ($analysis_id ? " AND analysis_id='$analysis_id'" : ''); SELECT count(*)
FROM worker
WHERE status!='DEAD'
} . ($analysis_id ? " AND analysis_id='$analysis_id'" : '');
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
$sth->execute(); $sth->execute();
...@@ -852,25 +857,27 @@ sub print_analysis_status { ...@@ -852,25 +857,27 @@ sub print_analysis_status {
sub print_running_worker_counts { sub print_running_worker_counts {
my $self = shift; my $self = shift;
print "\n===== Stats of live Workers according to the Queen: ======\n"; my $sql = qq{
my $sql = qq{ SELECT logic_name, count(*) SELECT logic_name, count(*)
FROM worker FROM worker w
JOIN analysis_base USING(analysis_id) JOIN analysis_base USING(analysis_id)
WHERE worker.cause_of_death='' WHERE w.status!='DEAD'
GROUP BY worker.analysis_id GROUP BY analysis_id
}; };
my $total_workers = 0; my $total_workers = 0;
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
$sth->execute(); $sth->execute();
while((my $logic_name, my $worker_count)=$sth->fetchrow_array()) {
printf("%30s : %d workers\n", $logic_name, $worker_count); print "\n===== Stats of live Workers according to the Queen: ======\n";
$total_workers += $worker_count; while((my $logic_name, my $worker_count)=$sth->fetchrow_array()) {
} printf("%30s : %d workers\n", $logic_name, $worker_count);
$sth->finish; $total_workers += $worker_count;
printf("%30s : %d workers\n\n", '======= TOTAL =======', $total_workers); }
$sth->finish;
printf("%30s : %d workers\n\n", '======= TOTAL =======', $total_workers);
} }
...@@ -899,8 +906,9 @@ sub monitor { ...@@ -899,8 +906,9 @@ sub monitor {
sum(work_done/(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(born)))/count(*), } sum(work_done/(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(born)))/count(*), }
). qq{ ). qq{
group_concat(DISTINCT logic_name) group_concat(DISTINCT logic_name)
FROM worker left join analysis_base USING (analysis_id) FROM worker w
WHERE cause_of_death = '' LEFT JOIN analysis_base USING (analysis_id)
WHERE w.status!='DEAD'
}; };
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
...@@ -922,7 +930,7 @@ sub register_all_workers_dead { ...@@ -922,7 +930,7 @@ sub register_all_workers_dead {
my $overdueWorkers = $self->fetch_overdue_workers(0); my $overdueWorkers = $self->fetch_overdue_workers(0);
foreach my $worker (@{$overdueWorkers}) { foreach my $worker (@{$overdueWorkers}) {
$worker->cause_of_death( 'FATALITY' ); # well, maybe we could have investigated further... $worker->cause_of_death( 'UNKNOWN' ); # well, maybe we could have investigated further...
$self->register_worker_death($worker); $self->register_worker_death($worker);
} }
} }
......
# Adding the (default) NULL option and renaming 'FATALITY'-->'UNKNOWN'
ALTER TABLE worker MODIFY COLUMN cause_of_death enum('NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'UNKNOWN') DEFAULT NULL;
...@@ -82,7 +82,7 @@ CREATE TABLE worker ( ...@@ -82,7 +82,7 @@ CREATE TABLE worker (
born timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, born timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_check_in datetime NOT NULL, last_check_in datetime NOT NULL,
died datetime DEFAULT NULL, died datetime DEFAULT NULL,
cause_of_death enum('', 'NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'FATALITY') DEFAULT '' NOT NULL, cause_of_death enum('NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'UNKNOWN') DEFAULT NULL,
log_dir varchar(80) DEFAULT NULL, log_dir varchar(80) DEFAULT NULL,
PRIMARY KEY (worker_id), PRIMARY KEY (worker_id),
......
...@@ -75,7 +75,7 @@ CREATE TABLE worker ( ...@@ -75,7 +75,7 @@ CREATE TABLE worker (
born timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, born timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_check_in datetime NOT NULL, last_check_in datetime NOT NULL,
died datetime DEFAULT NULL, died datetime DEFAULT NULL,
cause_of_death TEXT DEFAULT '' NOT NULL, /* enum('', 'NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'FATALITY') DEFAULT '' NOT NULL */ cause_of_death TEXT DEFAULT NULL, /* enum('NO_WORK', 'JOB_LIMIT', 'HIVE_OVERLOAD', 'LIFESPAN', 'CONTAMINATED', 'KILLED_BY_USER', 'MEMLIMIT', 'RUNLIMIT', 'UNKNOWN') DEFAULT NULL */
log_dir varchar(80) DEFAULT NULL log_dir varchar(80) DEFAULT NULL
); );
......
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