diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 9af6e4e86..f7b8a5a6a 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,6 +6,9 @@ - Added pagination to purchase history in commerce. - improved performance of EMS - upgraded YUI to 2.2.2 and YUI-ext to 1.0.1a + - Improved error handling in Spectre when WebGUI hands it bad data. + - Fixed a problem where Spectre dropped cron jobs that were erroring + consistently. - rfe: snippets should have titles too! - Added a mechanism for using external folders for custom code. See sbin/preload.custom.example for details. diff --git a/lib/Spectre/Cron.pm b/lib/Spectre/Cron.pm index 045f956cb..2fc15aadd 100644 --- a/lib/Spectre/Cron.pm +++ b/lib/Spectre/Cron.pm @@ -127,9 +127,14 @@ An integer (1,2,3) that determines what priority the workflow should be executed sub addJob { my ($self, $params) = @_[OBJECT, ARG0]; my $id = $params->{config}."-".$params->{taskId}; - $self->debug("Adding schedule ".$params->{taskId}." to the queue."); - $params->{schedule} = join(" ", $params->{minuteOfHour}, $params->{hourOfDay}, $params->{dayOfMonth}, $params->{monthOfYear}, $params->{dayOfWeek}); - $self->{_jobs}{$id} = $params; + if ($params->{config} eq "" || $params->{taskId}) { + $self->error("Can't add a schedule with missing data: $id"); + } + else { + $self->debug("Adding schedule ".$params->{taskId}." to the queue."); + $params->{schedule} = join(" ", $params->{minuteOfHour}, $params->{hourOfDay}, $params->{dayOfMonth}, $params->{monthOfYear}, $params->{dayOfWeek}); + $self->{_jobs}{$id} = $params; + } } #------------------------------------------------------------------- @@ -274,7 +279,6 @@ The unique ID for this job. sub deleteJob { my ($self, $id) = @_[OBJECT, ARG0]; $self->debug("Deleting schedule ".$id." from queue."); - delete $self->{_errorCount}{$id}; delete $self->{_jobs}{$id}; } @@ -406,9 +410,6 @@ sub runJob { if ($job->{sitename} eq "" || $job->{config} eq "" || $job->{taskId} eq "") { $self->error("A job has corrupt information and is not able to be run. Skipping execution."); $kernel->yield("deleteJob",$id); - } elsif ($self->{_errorCount}{$id} >= 5) { - $self->error("Job ".$id." has failed ".$self->{_errorCount}{$id}." times in a row and will no longer attempt to execute."); - $kernel->yield("deleteJob",$id); } else { my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").$job->{gateway}; my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}]; @@ -450,29 +451,24 @@ sub runJobResponse { } my $state = $response->content; if ($state eq "done") { - delete $self->{_errorCount}{$id}; $self->debug("Job $id is now complete."); if ($job->{runOnce}) { $kernel->yield("deleteJob",$id); } } elsif ($state eq "error") { - $self->{_errorCount}{$id}++; $self->debug("Got an error response for job $id, will try again in ".$self->config->get("suspensionDelay")." seconds."); $kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$id); } else { - $self->{_errorCount}{$id}++; $self->error("Something bad happened on the return of job $id, will try again in ".$self->config->get("suspensionDelay")." seconds. ".$response->error_as_HTML); $kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$id); } } else { - $self->{_errorCount}{$id}++; $self->error("Job $id is not in our queue."); } } elsif ($response->is_redirect) { $self->error("Response for $id was redirected. This should never happen if configured properly!!!"); } elsif ($response->is_error) { $self->error("Response for job $id had a communications error. ".$response->error_as_HTML); - $self->{_errorCount}{$id}++; $kernel->delay_set("runJob",$self->config->get("suspensionDelay"),$id); } } diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index 9c4b5e5fb..231b5d5a8 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -79,10 +79,14 @@ The priority (1,2, or 3) that this instance should be run at. sub addInstance { my ($self, $instance) = @_[OBJECT, ARG0]; - my $priority = ($instance->{priority} -1) * 10; - $instance->{lastState} = "never run"; - $self->debug("Adding workflow instance ".$instance->{instanceId}." from ".$instance->{sitename}." to queue at priority ".$priority."."); - $self->getWaitingQueue->enqueue($priority, $instance); + if ($instance->{priority} < 1 || $instance->{instanceId} eq "" || $instance->{sitename} eq "") { + $self->error("Can't add workflow instance with missing data: ". $instance->{sitename}." - ".$instance->{instanceId}); + } else { + my $priority = ($instance->{priority} -1) * 10; + $instance->{lastState} = "never run"; + $self->debug("Adding workflow instance ".$instance->{instanceId}." from ".$instance->{sitename}." to queue at priority ".$priority."."); + $self->getWaitingQueue->enqueue($priority, $instance); + } } #-------------------------------------------------------------------