Skip to content

Commit

Permalink
Merge pull request #8 from Peatix/ignore-error-for-saving-exitstatus
Browse files Browse the repository at this point in the history
Ignore exceptions while saving exitstatus
  • Loading branch information
aklaswad authored Mar 18, 2021
2 parents 0abe737 + a68b662 commit 4397dd1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/TheSchwartz/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,27 @@ sub set_exit_status {
}

my $driver = $job->driver;
$driver->insert($status);
eval {
$driver->insert($status);
};
if ( my $e = $@ ) {
my $jobid = $job->jobid;
if ( $e =~ /Failed to execute INSERT INTO exitstatus/
&& $e =~ /Duplicate entry/ ) {
# Already saved exitstatus, it means this job was
# already executed.
# Ignore this...
print STDERR "Got duplicated entry for exitstatus($exit) of job $jobid: $e\n";
print STDERR Dumper $job;
}
else {
print STDERR "Got an error when saving exitstatus($exit) of job $jobid: $e\n";
print STDERR Dumper $job;
}

# Anyway, we can't do anything here. Just ignore the exception.
}


# and let's lazily clean some exitstatus while we're here. but
# rather than doing this query all the time, we do it 1/nth of the
Expand Down

0 comments on commit 4397dd1

Please sign in to comment.