在 Laravel 6 ,队列任务失败后,异常信息未写入表 failed_jobs 中
1、当一个队列任务失败后,执行到 任务失败后清理 failed 方法。抛出异常,发现与 telescope 有关
[2023-11-20 17:25:42] local.ERROR: file_get_contents(E:\wwwroot\object\storage\app\theme_downloads\2023\11\20\1700472319.9435.1423840798\migrations\migrate_settings_data.php): failed to open stream: No such file or directory { "exception": "[object] (ErrorException(code: 0): file_get_contents(E:\\wwwroot\\wshop\\platform\\storage\\app\\theme_downloads\\2023\\11\\20\\1700472319.9435.1423840798\\migrations\\migrate_settings_data.php): failed to open stream: No such file or directory at E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\telescope\\src\\ExceptionContext.php:45) [stacktrace] #0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'file_get_conten...', 'E:\\\\wwwroot\\\\wsho...', 45, Array) #1 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\telescope\\src\\ExceptionContext.php(45): file_get_contents('E:\\\\wwwroot\\\\wsho...') #2 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\telescope\\src\\ExceptionContext.php(19): Laravel\\Telescope\\ExceptionContext::getFileContext(Object(ErrorException)) #3 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\telescope\\src\\Watchers\\JobWatcher.php(108): Laravel\\Telescope\\ExceptionContext::get(Object(ErrorException)) #4 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Events\\Dispatcher.php(369): Laravel\\Telescope\\Watchers\\JobWatcher->recordFailedJob(Object(Illuminate\\Queue\\Events\\JobFailed)) #5 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Events\\Dispatcher.php(218): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Queu...', Array) #6 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Jobs\\Job.php(185): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Queu...') #7 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(482): Illuminate\\Queue\\Jobs\\Job->fail(Object(ErrorException)) #8 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(469): Illuminate\\Queue\\Worker->failJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(ErrorException)) #9 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(399): Illuminate\\Queue\\Worker->markJobAsFailedIfWillExceedMaxAttempts('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), 1, Object(ErrorException)) #10 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(372): Illuminate\\Queue\\Worker->handleJobException('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions), Object(ErrorException)) #11 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(314): Illuminate\\Queue\\Worker->process('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions)) #12 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(134): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), 'redis', Object(Illuminate\\Queue\\WorkerOptions)) #13 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(112): Illuminate\\Queue\\Worker->daemon('redis', 'default', Object(Illuminate\\Queue\\WorkerOptions)) #14 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'default') #15 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle() #16 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #17 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #18 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #19 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(590): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #20 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(134): Illuminate\\Container\\Container->call(Array) #21 E:\\wwwroot\\wshop\\platform\\vendor\\symfony\\console\\Command\\Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #22 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #23 E:\\wwwroot\\wshop\\platform\\vendor\\symfony\\console\\Application.php(1021): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #24 E:\\wwwroot\\wshop\\platform\\vendor\\symfony\\console\\Application.php(275): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #25 E:\\wwwroot\\wshop\\platform\\vendor\\symfony\\console\\Application.php(149): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #26 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Application.php(93): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #27 E:\\wwwroot\\wshop\\platform\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(131): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #28 E:\\wwwroot\\wshop\\platform\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #29 {main} " }
2、使用 queue:work Artisan 命令运行处理器,发现队列任务一直未结束,也未失败。如图1
PS E:\wwwroot\object> php artisan queue:work [2023-11-20 17:25:19][4kBhJcMDrWBEuf8ZWskA9ikQlGbu9kBL] Processing: Modules\ThemeStoreDb\Jobs\InstallThemeToDb
3、查看表 failed_jobs 中,也未新增加记录。如图2
4、在 .env 文件,禁用 telescope ,再次执行队列任务,表 failed_jobs 中已经成功增加新记录。如图3
TELESCOPE_ENABLED=false
5、还原第 4 步骤,根源应该在于执行了 View::addLocation($this->location); 方法所导致,也执行了方法 View::flushFinderCache(); 。然后又删除掉了目录 $this->location。决定不再删除目录 $this->location。使用 queue:work Artisan 命令运行处理器,发现队列任务已经失败。且 表 failed_jobs 中,也已经新增加记录。如图4
近期评论