mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
https://www.mongodb.com/docs/drivers/php/laravel-mongodb/
MIT License
7.02k stars 1.43k forks source link

Queue retry gets failed : Unable to find failed job with ID [] #3000

Open v4mp1re opened 5 months ago

v4mp1re commented 5 months ago

Description:

When queue:retry is run it returns Unable to find failed job with ID [] error for each items in queue.

Steps to reproduce

  1. Configure failed job with mongodb
  2. Fail a job
  3. retry failed job with php artisan queue:retry all

Expected behaviour

Failed jobs should be queued back to jobs table

Actual behaviour

Retrying fails. in Queue:retry command

$ids = method_exists($failer, 'ids') ? $failer->ids($queue) : collect($failer->all()) ->where('queue', $queue) ->pluck('id') ->toArray();

the failer provider is MongoDB\Laravel\Queue\Failed\MongoFailedJobProvider::class which extends Illuminate\Queue\Failed\DatabaseFailedJobProvider::class .

MongoFailedJobProvider::class does not override DatabaseFailedJobProvider::class's ids() function. The ids function is implemeted based on the myssql which tries to get 'id' of the failed job instead of '_id' in the case of Mongodb

hans-thomas commented 1 week ago

Hi @GromNaN, I worked on this issue for a couple of hours and found out the MongoDBQueueServiceProvider class and other related classes are removed in version 5,x. what's going on? currently, does the laravel-mongodb package support queues?

PS: the documentation needs an update.

GromNaN commented 1 week ago

The queue mechanism is still supported. The custom connector is registered in MongoDBServiceProvider

The custom FailedJobProvider was removed because it was a copy of DatabaseFailedJobProvider with specific transformations id/_id, object/array and Carbon/UTCDateTime that are now done by default by MongoDB Query Builder in version 5.

@v4mp1re doesn't tell in which laravel-mongodb version is the issue. I think it was fixed in version 4.3 by https://github.com/mongodb/laravel-mongodb/pull/2838