skip to Main Content

I’ve got a batch of silenced jobs (+/- 7k every hour), which are running correctly and completed. Normally the completed jobs are cleared after 1 hour, but the silenced jobs are standing in Redis for 7 days. This seems a bit odd to me and it’s taking up a lot of space in Redis.

Horizon Config:

/*
    |--------------------------------------------------------------------------
    | Job Trimming Times
    |--------------------------------------------------------------------------
    |
    | Here you can configure for how long (in minutes) you desire Horizon to
    | persist the recent and failed jobs. Typically, recent jobs are kept
    | for one hour while all failed jobs are stored for an entire week.
    |
    */

    'trim' => [
        'recent' => 60,
        'pending' => 60,
        'completed' => 60,
        'recent_failed' => 10080,
        'failed' => 10080,
        'monitored' => 10080,
    ],

Job:

class ClearCategorySkusJob implements ShouldBeUnique, ShouldQueue, Silenced {
    use Dispatchable, Queueable;

    public int $tries = 3;

    public function __construct(
        private readonly string $category,
        private readonly string $domain,
    ) {
        $this->onQueue('cache');
    }

    public function handle(): void {}
    
    public function uniqueId(): string {}

    public function tags(): array {}

}
  • PHP version: 8.2.26
  • Redis version: 6.2.13
  • Laravel version: 10.48.24
  • Horizon version: 5.24.3

2

Answers


  1. Chosen as BEST ANSWER

    We had a monitor for one of the tags. When a monitor is set it will always be saved for 7 days.

    Deleted the monitor and it was working correctly again.


  2. Horizon might treat silenced jobs differently, possibly falling under the monitored category, which is set to 7 days (10080 minutes) in your config.

    Can you try reducing the monitored trim time in the config to a lower value (e.g 60 minutes) and observe if that clears out the silenced jobs sooner?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search