From 72d9cc3a0cd647513634b2b0cca8cf79b5de8245 Mon Sep 17 00:00:00 2001 From: Ollie Date: Tue, 17 Feb 2026 09:40:23 +0000 Subject: [PATCH] Add $tries and releaseAfter() for ElasticSearchAliasInit job Prevent the `WithoutOverlapping` middleware from causing jobs to fail due to `MaxAttemptsExceededException` Bug: T416158 --- app/Jobs/ElasticSearchAliasInit.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Jobs/ElasticSearchAliasInit.php b/app/Jobs/ElasticSearchAliasInit.php index 651448ad..3fdfb2ae 100644 --- a/app/Jobs/ElasticSearchAliasInit.php +++ b/app/Jobs/ElasticSearchAliasInit.php @@ -19,6 +19,10 @@ class ElasticSearchAliasInit extends Job { public readonly string $sharedPrefix; + // Set $tries to 0 to enable unlimited retries for this job + // https://laravel.com/docs/10.x/queues#max-attempts + public int $tries = 0; + public function __construct(int $wikiId, string $esHost, ?string $sharedPrefix = null) { $this->wikiId = $wikiId; $this->esHost = $esHost; @@ -32,8 +36,9 @@ public function __construct(int $wikiId, string $esHost, ?string $sharedPrefix = */ public function middleware(): array { return [ - // Only allow one job per ES host to run at a time to avoid DoSing the ES cluster with alias updates - new WithoutOverlapping("elasticsearch-alias-init-{$this->esHost}"), + // Only allow one job per ES host to run at a time to avoid DoSing the ES cluster with alias updates. + // This job will only be retried after 15 seconds if another job for the same ES host is currently running. + (new WithoutOverlapping("elasticsearch-alias-init-{$this->esHost}"))->releaseAfter(15), ]; }