diff --git a/src/Services/QueuedJobService.php b/src/Services/QueuedJobService.php index 5411ba18..354eab61 100644 --- a/src/Services/QueuedJobService.php +++ b/src/Services/QueuedJobService.php @@ -9,7 +9,6 @@ use SilverStripe\Control\Email\Email; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Configurable; -use SilverStripe\Core\Convert; use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injectable; use SilverStripe\Core\Injector\Injector; @@ -551,9 +550,12 @@ protected function grabMutex(QueuedJobDescriptor $jobDescriptor) // and thus the row would always be affected. try { DB::query(sprintf( - 'UPDATE "QueuedJobDescriptor" SET "JobStatus" = \'%s\' WHERE "ID" = %s', + 'UPDATE "QueuedJobDescriptor" SET "JobStatus" = \'%s\' WHERE "ID" = %s' + . ' AND "JobFinished" IS NULL AND "JobStatus" NOT IN (%s)', QueuedJob::STATUS_INIT, - $jobDescriptor->ID + $jobDescriptor->ID, + "'" . QueuedJob::STATUS_RUN . "', '" . QueuedJob::STATUS_COMPLETE . "', '" + . QueuedJob::STATUS_PAUSED . "', '" . QueuedJob::STATUS_CANCELLED . "'" )); } catch (Exception $e) { return false;