我有以下环境,我注意到作业在2分钟后随机排队两次:
我使用以下代码:
$queue = new Pheanstalk\Pheanstalk("127.0.0.1:14803");
$queue->watch("tubeDelete");
while ($job = $queue->reserve()) {
$log->write("Entering Job {$job->getId()} \n");
$log->write("Job {$job->getId()} data : {$job->getData()} \n");
$data = json_decode($job->getData(), true);
try {
$deleteResponse = $client->deleteClient($clientId)
if($deleteResponse){
$log->write("client $clientId deleted successfully");
$queue->delete($job);
}else{
$log->write("Failed to delete client $clientId, check the log file");
$queue->bury($job);
}
} catch (Exception $e) {
$log->write("Failed to delete client $clientId with PHP exception, check the log file");
$queue->bury($job);
}
}
日志文件:
Fri, 08 Dec 2017 13:00:23 +0200 Entering Job 92428501
Fri, 08 Dec 2017 13:00:23 +0200 Job 92428501 data : {"clientId":"1397"}
Fri, 08 Dec 2017 13:00:24 +0200 Client 1397 deleted successfully
Fri, 08 Dec 2017 13:00:24 +0200 Entering Job 92428502
Fri, 08 Dec 2017 13:00:24 +0200 Job 92428502 data : {"clientId":"1398"}
Fri, 08 Dec 2017 13:00:26 +0200 Client 1398 deleted successfully
Fri, 08 Dec 2017 13:00:26 +0200 Entering Job 92428503
Fri, 08 Dec 2017 13:00:26 +0200 Job 92428503 data : {"clientId":"1399"}
Fri, 08 Dec 2017 13:00:28 +0200 Client 1399 deleted successfully
Fri, 08 Dec 2017 13:00:28 +0200 Entering Job 92428504
Fri, 08 Dec 2017 13:00:28 +0200 Job 92428504 data : {"clientId":"1401"}
Fri, 08 Dec 2017 13:00:30 +0200 Client 1401 deleted successfully
Fri, 08 Dec 2017 13:00:30 +0200 Entering Job 92428505
Fri, 08 Dec 2017 13:00:30 +0200 Job 92428505 data : {"clientId":"1402"}
Fri, 08 Dec 2017 13:00:31 +0200 Client 1402 deleted successfully
Fri, 08 Dec 2017 13:00:31 +0200 Entering Job 92428506
Fri, 08 Dec 2017 13:00:31 +0200 Job 92428506 data : {"clientId":"1403"}
Fri, 08 Dec 2017 13:00:33 +0200 Client 1403 deleted successfully
Fri, 08 Dec 2017 13:00:33 +0200 Entering Job 92428507
Fri, 08 Dec 2017 13:00:33 +0200 Job 92428507 data : {"clientId":"1404"}
Fri, 08 Dec 2017 13:00:34 +0200 Client 1404 deleted successfully
Fri, 08 Dec 2017 13:00:34 +0200 Entering Job 92428508
Fri, 08 Dec 2017 13:00:34 +0200 Job 92428508 data : {"clientId":"1405"}
Fri, 08 Dec 2017 13:00:36 +0200 Client 1405 deleted successfully
Fri, 08 Dec 2017 13:00:36 +0200 Entering Job 92428509
Fri, 08 Dec 2017 13:00:36 +0200 Job 92428509 data : {"clientId":"1409"}
Fri, 08 Dec 2017 13:00:37 +0200 Client 1409 deleted successfully
Fri, 08 Dec 2017 13:00:37 +0200 Entering Job 92428510
Fri, 08 Dec 2017 13:00:37 +0200 Job 92428510 data : {"clientId":"1421"}
Fri, 08 Dec 2017 13:00:38 +0200 Client 1421 deleted successfully
Fri, 08 Dec 2017 13:02:23 +0200 Entering Job 92428511
Fri, 08 Dec 2017 13:02:23 +0200 Job 92428511 data : {"clientId":"1397"}
Fri, 08 Dec 2017 13:02:23 +0200 Client 1397 deleted successfully
Fri, 08 Dec 2017 13:02:23 +0200 Entering Job 92428512
Fri, 08 Dec 2017 13:02:23 +0200 Job 92428512 data : {"clientId":"1398"}
Fri, 08 Dec 2017 13:02:23 +0200 Client 1398 deleted successfully
Fri, 08 Dec 2017 13:02:23 +0200 Entering Job 92428513
Fri, 08 Dec 2017 13:02:23 +0200 Job 92428513 data : {"clientId":"1399"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1399 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428514
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428514 data : {"clientId":"1401"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1401 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428515
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428515 data : {"clientId":"1402"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1402 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428516
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428516 data : {"clientId":"1403"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1403 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428517
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428517 data : {"clientId":"1404"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1404 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428518
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428518 data : {"clientId":"1405"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1405 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428519
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428519 data : {"clientId":"1409"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1409 deleted successfully
Fri, 08 Dec 2017 13:02:24 +0200 Entering Job 92428520
Fri, 08 Dec 2017 13:02:24 +0200 Job 92428520 data : {"clientId":"1421"}
Fri, 08 Dec 2017 13:02:24 +0200 Client 1421 deleted successfully
因此,您可以在2分钟后找到重复的客户端,例如:
Fri, 08 Dec 2017 13:00:23 +0200 Entering Job 92428501
Fri, 08 Dec 2017 13:00:23 +0200 Job 92428501 data : {"clientId":"1397"}
Fri, 08 Dec 2017 13:00:24 +0200 Client 1397 deleted successfully
Fri, 08 Dec 2017 13:02:23 +0200 Entering Job 92428511
Fri, 08 Dec 2017 13:02:23 +0200 Job 92428511 data : {"clientId":"1397"}
Fri, 08 Dec 2017 13:02:23 +0200 Client 1397 deleted successfully
是否与TTR / DEADLINE_SOON /配置问题或与supervisord相关的问题?