Skip to content

Commit 1e5a788

Browse files
committed
Release again if database deadlock occurred
1 parent 913ddfd commit 1e5a788

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Jobs/RabbitMQJob.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Contracts\Queue\Job as JobContract;
88
use Illuminate\Database\DetectsDeadlocks;
99
use Illuminate\Queue\Jobs\Job;
10+
use Illuminate\Support\Str;
1011
use PhpAmqpLib\Channel\AMQPChannel;
1112
use PhpAmqpLib\Message\AMQPMessage;
1213
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue;
@@ -113,7 +114,10 @@ public function release($delay = 0)
113114
try {
114115
$job = unserialize($body['data']['command']);
115116
} catch (Exception $exception) {
116-
if ($this->causedByDeadlock($exception)) {
117+
if (
118+
$this->causedByDeadlock($exception) ||
119+
Str::contains($exception->getMessage(), ['detected deadlock'])
120+
) {
117121
sleep(2);
118122
$this->release($delay);
119123
return;

0 commit comments

Comments
 (0)