gpt4 book ai didi

php - 从作业表中删除时 Laravel 队列死锁

转载 作者:行者123 更新时间:2023-12-05 05:10:28 25 4
gpt4 key购买 nike

<分区>

我刚刚让 Laravel Queue 与我的项目一起工作。我启用了 Supervisor,所以一切都是自动化的,但是当从作业表中删除作业时,就会发生死锁。我正在使用 MySQL 作为驱动程序。

我怎样才能阻止这些僵局?

Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: delete from `jobs` where `id` = 813)
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/controlapi/public_html/total-control-api/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=controlapi
numprocs=10
redirect_stderr=true
stdout_logfile=/home/controlapi/public_html/total-control-api/storage/logs/worker.log

编辑:下面是我在每个作业中运行的查询

DB::transaction(function() use ($decode, $status, $c_decode, $m_decode, $d_decode) {

try {
$query = DB::connection('mysql2')->statement('INSERT INTO transactions (json, uuid, status, divisionName, divisionUuid, merchantName, merchantUuid, channelName, channelUuid, channelLogin, channelPwd)
VALUES (:transaction_1, :uuid, :status_1, :divisionName, :divisionUuid, :merchantName, :merchantUuid, :channelName, :channelUuid, :channelLogin, :channelPwd)
ON DUPLICATE KEY UPDATE json = :transaction_2, status = :status_2',
array('transaction_1' => $this->transaction,
'transaction_2' => $this->transaction,
'uuid' => $decode->payload->id,
'status_1' => $status->status,
'status_2' => $status->status,
'divisionName' => $d_decode->divisionInfo->name,
'divisionUuid' => $d_decode->divisionInfo->id,
'merchantName' => $m_decode->merchantInfo->name,
'merchantUuid' => $m_decode->merchantInfo->id,
'channelName' => $c_decode->channelInfo->name,
'channelUuid' => $c_decode->channelInfo->channel,
'channelLogin' => $c_decode->channelInfo->login,
'channelPwd' => $c_decode->channelInfo->pwd));
}
catch(Exception $e) {
Storage::prepend('transactions_insert_errors.txt', Carbon::now('UTC')->toDateTimeString()."\nUUID:".$decode->payload->id."\n".$e->getMessage()."\n\n");
}
}, 5);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com