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

feature: jobless workers will now leave module compilation errors in the...

feature: jobless workers will now leave module compilation errors in the job_message table (thanks, Kathryn!)
parent 52e926fc
......@@ -220,7 +220,7 @@ sub warning {
my ($self, $msg) = @_;
if( my $job_adaptor = $self->adaptor ) {
$job_adaptor->db->get_JobMessageAdaptor()->register_message($self->dbID, $msg, 0);
$job_adaptor->db->get_JobMessageAdaptor()->store_job_message($self->dbID, $msg, 0);
} else {
print STDERR "Warning: $msg\n";
}
......
......@@ -621,7 +621,7 @@ sub release_undone_jobs_from_worker {
}
}
$self->db()->get_JobMessageAdaptor()->register_message($job_id, $msg, not $passed_on );
$self->db()->get_JobMessageAdaptor()->store_job_message($job_id, $msg, not $passed_on );
unless($passed_on) {
$self->release_and_age_job( $job_id, $max_retry_count, not $resource_overusage );
......
......@@ -6,7 +6,9 @@
=head1 SYNOPSIS
$dba->get_JobMessageAdaptor->register_message($job_id, $msg, $is_error);
$dba->get_JobMessageAdaptor->store_job_message($job_id, $msg, $is_error);
$dba->get_JobMessageAdaptor->store_worker_message($worker_id, $msg, $is_error);
=head1 DESCRIPTION
......@@ -31,14 +33,14 @@ sub default_table_name {
}
sub register_message {
sub store_job_message {
my ($self, $job_id, $msg, $is_error) = @_;
chomp $msg; # we don't want that last "\n" in the database
my $table_name = $self->table_name();
# (the timestamp 'time' column will be set automatically)
# Note: the timestamp 'time' column will be set automatically
my $sql = qq{
INSERT INTO $table_name (job_id, worker_id, retry, status, msg, is_error)
SELECT job_id, worker_id, retry_count, status, ?, ?
......@@ -50,5 +52,24 @@ sub register_message {
$sth->finish();
}
sub store_worker_message {
my ($self, $worker_id, $msg, $is_error) = @_;
chomp $msg; # we don't want that last "\n" in the database
my $table_name = $self->table_name();
# Note: the timestamp 'time' column will be set automatically
my $sql = qq{
INSERT INTO $table_name (worker_id, status, msg, is_error)
SELECT worker_id, status, ?, ?
FROM worker WHERE worker_id=?
};
my $sth = $self->prepare( $sql );
$sth->execute( $msg, $is_error ? 1 : 0, $worker_id );
$sth->finish();
}
1;
......@@ -533,6 +533,7 @@ sub run {
} or do {
my $msg = "Could not compile Runnable '".$self->analysis->module."' :\n\t".$@;
warn "$msg\n";
$self->adaptor->db->get_JobMessageAdaptor()->store_worker_message($self->dbID, $msg, 1 );
$self->cause_of_death('CONTAMINATED');
}
......@@ -689,7 +690,7 @@ sub run_one_batch {
my $job_status_at_the_moment = $job->status();
my $action = $job->incomplete ? 'died' : 'exited';
$job_completion_line = "\njob $job_id : $action in status '$job_status_at_the_moment' for the following reason: $msg_thrown\n";
$self->adaptor->db->get_JobMessageAdaptor()->register_message($job_id, $msg_thrown, $job->incomplete );
$self->adaptor->db->get_JobMessageAdaptor()->store_job_message($job_id, $msg_thrown, $job->incomplete );
}
print STDERR $job_completion_line if($self->log_dir and ($self->debug or $job->incomplete)); # one copy goes to the job's STDERR
......
# allow job_id and retry to be NULL by default, to make it possible for jobless workers to leave messages:
ALTER TABLE job_message MODIFY COLUMN job_id int(10) DEFAULT NULL;
ALTER TABLE job_message MODIFY COLUMN retry int(10) DEFAULT NULL;
# re-route getting analysis_id/logic_name via worker table, so that it would work in the absence of the job:
CREATE OR REPLACE VIEW msg AS
SELECT a.analysis_id, a.logic_name, m.*
FROM job_message m
JOIN worker w USING (worker_id)
JOIN analysis_base a USING (analysis_id)
LEFT JOIN job j USING (job_id);
......@@ -34,8 +34,9 @@ CREATE OR REPLACE VIEW progress AS
CREATE OR REPLACE VIEW msg AS
SELECT a.analysis_id, a.logic_name, m.*
FROM job_message m
JOIN job j USING (job_id)
JOIN analysis_base a USING (analysis_id);
JOIN worker w USING (worker_id)
JOIN analysis_base a USING (analysis_id)
LEFT JOIN job j USING (job_id);
#### time an analysis or group of analyses (given by a name pattern) ######################################
......
......@@ -34,6 +34,7 @@ CREATE VIEW IF NOT EXISTS progress AS
CREATE VIEW IF NOT EXISTS msg AS
SELECT a.analysis_id, a.logic_name, m.*
FROM job_message m
JOIN job j USING (job_id)
JOIN analysis_base a USING (analysis_id);
JOIN worker w USING (worker_id)
JOIN analysis_base a USING (analysis_id)
LEFT JOIN job j ON (m.job_id=j.job_id);
......@@ -231,10 +231,10 @@ CREATE TABLE job (
CREATE TABLE job_message (
job_message_id int(10) NOT NULL AUTO_INCREMENT,
job_id int(10) NOT NULL,
job_id int(10) DEFAULT NULL,
worker_id int(10) unsigned NOT NULL,
time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
retry int(10) DEFAULT 0 NOT NULL,
retry int(10) DEFAULT NULL,
status enum('UNKNOWN','COMPILATION','PRE_CLEANUP','FETCH_INPUT','RUN','WRITE_OUTPUT','POST_CLEANUP','PASSED_ON') DEFAULT 'UNKNOWN',
msg text,
is_error TINYINT,
......
......@@ -215,10 +215,10 @@ CREATE INDEX IF NOT EXISTS worker_idx ON job (worker_id);
CREATE TABLE job_message (
job_message_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
job_id INTEGER NOT NULL,
job_id INTEGER DEFAULT NULL,
worker_id INTEGER NOT NULL,
time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
retry int(10) DEFAULT 0 NOT NULL,
retry int(10) DEFAULT NULL,
status TEXT DEFAULT 'UNKNOWN', /* enum('UNKNOWN', 'COMPILATION', 'FETCH_INPUT', 'RUN', 'WRITE_OUTPUT', 'PASSED_ON') DEFAULT 'UNKNOWN', */
msg TEXT,
is_error BOOLEAN
......
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