Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions app/code/Magento/Cron/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
);
}

/**
* though running status is set in tryLockJob we must set it here because the object
* was loaded with a pending status and will set it back to pending if we don't set it here
*/
$schedule->setStatus(Schedule::STATUS_RUNNING)->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))->save();
$schedule->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))->save();

call_user_func_array($callback, array($schedule));

Expand Down
8 changes: 6 additions & 2 deletions app/code/Magento/Cron/Model/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ public function getNumeric($value)
*/
public function tryLockJob()
{
return $this->_getResource()->trySetJobStatusAtomic(
if ($this->_getResource()->trySetJobStatusAtomic(
$this->getId(),
self::STATUS_RUNNING,
self::STATUS_PENDING
);
)) {
$this->setStatus(self::STATUS_RUNNING);
return true;
}
return false;
}
}