skip to Main Content

I’m using Laravel Horizon which has a Failed Jobs section which used to work fine. Until I added the Sentry notification for failed jobs, in Job’s Class.

/**
 * Handle a job failure.
 *
 * @return void
 */
public function failed(Exception $exception)
{
    if ( app()->bound('sentry') ) {
        app('sentry')->captureException($exception);
    }
}

Now, when visiting the Failed Jobs tab in Horizon – it results in fatal error with memory exceeded. How can I make both Horizon and this sentry notification work?

2

Answers


  1. You can start and increasing memory, following the "How to increase the PHP memory_limit for better performance?" article from Vaishnavi Parameswaran.

    But check also if the memory limitation actually comes from the OS instead of PHP, as explained here.

    The 2018 laravel/horizon issues 375 also referenced laravel/horizon/src/Listeners/MonitorMasterSupervisorMemory.php as a possible cause.

            if ($master->memoryUsage() > config('horizon.memory_limit', 64)) {
                $master->terminate(12);
    

    So double-check your laravel/horizon/config/horizon.php setting.


    As in laravel/horizon issue 748, check your sentry.io errors for a line similar to:

    Invoked Artisan command: horizon:work -- input | 'horizon:work' redis --delay=0 --memory=128 --queue=default --sleep=3 --timeout=60 --tries=2 --supervisor='b396ac2bb269-E0QY:supervisor-1'
    

    Again, you will see a --memory argument which could have an impact here.

    Login or Signup to reply.
  2. You can create command to clean up older records of failed_jobs table.

    public function handle()
    {
        // mention days count as required
        DB::table('failed_jobs')->where('failed_at', '<', now()->subDays(10))->delete();
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search