laravel / horizon

Dashboard and code-driven configuration for Laravel queues.
https://laravel.com/docs/horizon
MIT License
3.86k stars 655 forks source link

ProcessPendingUpdates #1291

Closed hipoagencia closed 1 year ago

hipoagencia commented 1 year ago

Horizon Version

5.15

Laravel Version

10.13

PHP Version

8.1

Redis Driver

Predis

Redis Version

Last

Database Driver & Version

Centos

Description

Hello!

When I'm running on the online server, after finishing the entire queue, these processes keep appearing. Can you tell what it could be? Look the screenshot

Ver se descobre

Thanks

Steps To Reproduce

Just send jobs to Horizon

lucaspanik commented 1 year ago

@hipoagencia

Could it have something to do with it? https://github.com/laravel/telescope/pull/1349

hipoagencia commented 1 year ago

@lucaspanik

Hey, thanks for your suggestion. Looks like you got the anwser. I will make time to follow all the messages in this topic. Thanks for your help

pyrou commented 1 year ago

This looks definitely related. Telescope 4.15 introduce this new Laravel\Telescope\Jobs\ProcessPendingUpdates Job.

As I understood how it supposed to work, when the JobWatcher call a Telescope::recordUpdate() (when job being processed OR when job failed) an update is pushed to the Telescope::$updatesQueue. This cause a ProcessPendingUpdates dispatch (see Telescope::store() implementation)

Problem is, we mostly all have $entry->isFailedJob() condition in our TelescopeServiceProvider, to only store failed job in telescope. So a "normal" job does NOT exists in telescope_entries table.

Because of this, the telescope_entries can't be updated, and is pushed again here. As $failedUpdates not empty, ProcessPendingUpdates job is retried 10sec later.

So each normal Job, generate 3 extra ProcessPendingUpdates job.

@nunomaduro may help on this ?

nunomaduro commented 1 year ago

The goal of this particular job is process any pending updates on Telescope. So, we probably should ignore it on Horizon somehow. Can you make a pull request (and test it locally) on that @hipoagencia ?

hipoagencia commented 1 year ago

This looks definitely related. Telescope 4.15 introduce this new Laravel\Telescope\Jobs\ProcessPendingUpdates Job.

As I understood how it supposed to work, when the JobWatcher call a Telescope::recordUpdate() (when job being processed OR when job failed) an update is pushed to the Telescope::$updatesQueue. This cause a ProcessPendingUpdates dispatch (see Telescope::store() implementation)

Problem is, we mostly all have $entry->isFailedJob() condition in our TelescopeServiceProvider, to only store failed job in telescope. So a "normal" job does NOT exists in telescope_entries table.

Because of this, the telescope_entries can't be updated, and is pushed again here. As $failedUpdates not empty, ProcessPendingUpdates job is retried 10sec later.

So each normal Job, generate 3 extra ProcessPendingUpdates job.

@nunomaduro may help on this ?

Perfect explanation, thanks for your time.

hipoagencia commented 1 year ago

The goal of this particular job is process any pending updates on Telescope. So, we probably should ignore it on Horizon somehow. Can you make a pull request (and test it locally) on that @hipoagencia ?

Okay! I'm late to travel and i dont have time to do this right now. But, as soon as i can, i will do. Thanks for your help. (@nunomaduro by the way, Thanks for the awesome job with Laravel and everything that comes with)

trin4ik commented 7 months ago

I use telescope and horizon in my app too, and also faced the same problem. i need telescope mainly for excepеions etc, so i decided to act roughly. https://github.com/laravel/telescope/blob/4.x/src/Telescope.php#L672C36-L672C50 This is the only place where ProcessPendingUpdates is called, as we can see, it is enough to throw a variable $_ENV['VAPOR_SSM_PATH']. my app is running in k8s, I just added VAPOR_SSM_PATH: false to ConfigMap and jobs are not created.