Skip to content

Commit 74a6624

Browse files
committed
Add $tries and releaseAfter() for ElasticSearchAliasInit job
Prevent the `WithoutOverlapping` middleware from causing jobs to fail due to `MaxAttemptsExceededException` Bug: T416158
1 parent 33423a4 commit 74a6624

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/Jobs/ElasticSearchAliasInit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class ElasticSearchAliasInit extends Job {
1919

2020
public readonly string $sharedPrefix;
2121

22+
// Set $tries to 0 to enable unlimited retries for this job
23+
// https://laravel.com/docs/10.x/queues#max-attempts
24+
public int $tries = 0;
25+
2226
public function __construct(int $wikiId, string $esHost, ?string $sharedPrefix = null) {
2327
$this->wikiId = $wikiId;
2428
$this->esHost = $esHost;
@@ -33,7 +37,7 @@ public function __construct(int $wikiId, string $esHost, ?string $sharedPrefix =
3337
public function middleware(): array {
3438
return [
3539
// Only allow one job per ES host to run at a time to avoid DoSing the ES cluster with alias updates
36-
new WithoutOverlapping("elasticsearch-alias-init-{$this->esHost}"),
40+
(new WithoutOverlapping("elasticsearch-alias-init-{$this->esHost}"))->releaseAfter(15),
3741
];
3842
}
3943

0 commit comments

Comments
 (0)