最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

laravel - Silenced jobs not cleared correctly - Stack Overflow

programmeradmin3浏览0评论

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

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
Share Improve this question edited Jan 20 at 10:55 DarkBee 15.7k8 gold badges70 silver badges114 bronze badges asked Jan 20 at 10:48 Martijn BastiaansenMartijn Bastiaansen 75 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 1

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?

Our silenced jobs where monitored by a tag, and because the time for a monitored job to clear was 7 days, the silenced jobs where saved for 7 days. See the provided config, where monitored is set to 10080.

Normally a silenced job will be taken care of the same as a normal job, so normally it will be deleted in 1 day.

We deleted the monitor, so the silenced jobs went back to normal again.

发布评论

评论列表(0)

  1. 暂无评论