Currently Laravel Retry Command (queue:retry) fetch jobs by order id desc (->orderBy('id', 'desc')) see: DatabaseUuidFailedJobProvider::ids()
I've got two questions:
What's the reason for that? From my point of view failed jobs should be put back into the jobs queue in the same order they failed. I mean the first job that failed should be first job that will be moved to the jobs queue in order to be first consumed by queue:work command
How to change the implementation as the order in DatabaseUuidFailedJobProvider::ids() is hardcoded? Would it be enough to just extend DatabaseUuidFailedJobProvider and override the ids() method with different logic?
I think you misunderstand the point of failed jobs. In Laravel, failed job is failed because something went completely and unrecoverably wrong. It means you should review logs, analyze errors maybe adjust the code and only after that, maybe, retry the job to the queue (but not necessarily!)
If you always put all your failed jobs back to the queue for retrying, I think you should adjust jobs' settings ($retries, $backoff, retryUntil(), see here: https://laravel.com/docs/12.x/queues#max-job-attempts-and-timeout) so your job can 'retry itself' several times and become failed only if there is no another way.
By default, a job fails after first thrown exception and is not retried, this behavior should be adjusted in many cases.
You currect approach considers failed_jobs table as another queue for failed jobs, which it isn't.