Skip to content

Commit 3a25d14

Browse files
committed
Fix: Jobs sometimes run until max tries hit without hitting laravel's failure method'
Now referencing the AWS Batch provided AWS_BATCH_JOB_ATTEMPT environment variable to get job try count. Fall back to the db retry count if the environment variable doest not exist.
1 parent 7550b7e commit 3a25d14

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Jobs/BatchJob.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,18 @@ public function release($delay = 0)
4343

4444
$this->database->release($this->queue, $this->job, 0);
4545
}
46+
47+
/**
48+
* We override the base database attempts method to try to read out the
49+
* `AWS_BATCH_JOB_ATTEMPT` environment variable. If that fails, we fallback
50+
* to the db attempts count.
51+
*
52+
* https://docs.aws.amazon.com/batch/latest/userguide/job_env_vars.html
53+
*
54+
* @return int
55+
*/
56+
public function attempts()
57+
{
58+
return env('AWS_BATCH_JOB_ATTEMPT', parent::attempts());
59+
}
4660
}

0 commit comments

Comments
 (0)