SO I have a bit of a weird situation (and certain things cannot be changed which I'll highlight).
We have a Laravel 5.7 app with a single Job class. The job itself will fetch data and process it.
The amount of data (and therefore the length of time the job takes) can vary massively so wanted to have a dynamic timeout based on the runtime of the past n jobs (the details are stored so can be queried).
This is fine, I can dynamically work out the timeout value and set it as public $timeout = n as the job is posted to the queue.
The issue is that the retry_after value is set in the config/queue.php file and is read once so cannot be changed.
We want all jobs to be run just once, so I've got --tries=1 which is great, but it means this scenario can happen as an example:
- queue.php has timeout set to 30s
- scheduler calculates timeout required for this specific job to be 50s and sets that as job is put in queue
- job starts and passes 30s threshold
- next worker sees this and sets it as failed
I don't get how to set a dynamic retry_after value. If timeout can be dynamic it doesn't seem to make sense that retry_after has to be hard set.
I wanted to have it so that retry_after is timeout value plus a percentage over.
As I said about some things being locked, the time a job will run is totally dynamic, so having separate queues or a specific timeout isn't possible, it has to be calculated as its queued
It's also really infuriating that according to the divinglaravel posts he said:
- retry_after in config/queue.php is same as --retry_after on command line
- retryAfter as function or variable is NOT the same as either of the above, but is the same as --delay on command line
- delay as function or variable is NOT the same as --delay on command line