laravel / horizon

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

/horizon/failed cauing "Allowed memory size of 134217728 bytes exhausted" #1489

Closed gwidgery closed 3 months ago

gwidgery commented 3 months ago

Horizon Version

5.25

Laravel Version

10.48.16

PHP Version

8.1.2

Redis Driver

Predis

Redis Version

2.0.2

Database Driver & Version

MySQL 5.7

Description

We have deployed Horizon in production, and the jobs themselves are being processed fine. However, when we load the Horizon dashboard and go to the failed jobs tab we get this issue.

The front end fires the /horizon/api/jobs/failed?starting_at=0 request every few seconds. This causes an error in the backend of:

Symfony\Component\ErrorHandler\Error\FatalError Allowed memory size of 134217728 bytes exhausted (tried to allocate 139061374 bytes)

I can't find any pattern for when the issue happens. The number of failed jobs is very modest, and looking into the Horizon code it does not seem like it should be a heavy load on the server and cause a memory issue! I've tried increasing the memory limit to crazy high and still get the error.

Route:

vendor/laravel/horizon/routes
Route::get('/jobs/failed', 'FailedJobsController@index')->name('horizon.failed-jobs.index');

Controller:

namespace Laravel\Horizon\Http\Controllers;
class FailedJobsController extends Controller

public function index(Request $request)
    {
        $jobs = ! $request->query('tag')
                ? $this->paginate($request)
                : $this->paginateByTag($request, $request->query('tag'));

        $total = $request->query('tag')
                ? $this->tags->count('failed:'.$request->query('tag'))
                : $this->jobs->countFailed();

        return [
            'jobs' => $jobs,
            'total' => $total,
        ];
    }

Steps To Reproduce

Fresh install of Horizon

driesvints commented 3 months ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.