Skip to content

Commit

Permalink
Ignore exceptions while saving exitstatus
Browse files Browse the repository at this point in the history
Since it could break normal job closing and bring duplicated executions.
  • Loading branch information
aklaswad committed Mar 13, 2021
1 parent 0abe737 commit a68b662
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 a68b662

Please sign in to comment.