Skip to content

Commit

Permalink
aquire lock before deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 18, 2016
1 parent b4d6416 commit 4b502dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Illuminate/Queue/DatabaseQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ protected function markJobAsReserved($id)
*/
public function deleteReserved($queue, $id)
{
$this->database->table($this->table)->where('id', $id)->delete();
$this->database->beginTransaction();

if ($this->database->table($this->table)->lockForUpdate()->find($id)) {
$this->database->table($this->table)->where('id', $id)->delete();
}

$this->database->commit();
}

/**
Expand Down

0 comments on commit 4b502dc

Please sign in to comment.