From 4b502dc6eecd80efad01e845469b9a2bac26dae0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 18 May 2016 08:59:48 -0500 Subject: [PATCH] aquire lock before deleting --- src/Illuminate/Queue/DatabaseQueue.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/DatabaseQueue.php b/src/Illuminate/Queue/DatabaseQueue.php index 6a052a349b92..6aef0a17b2af 100644 --- a/src/Illuminate/Queue/DatabaseQueue.php +++ b/src/Illuminate/Queue/DatabaseQueue.php @@ -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(); } /**