Closed llioor closed 7 months ago
Having this same issue. Will try to attach as much details as possible.
php-mongodb version is 1.5.1 composer.json "jenssegers/mongodb": "^3.4" From composer.lock mongodb/mongodb 1.4.2 MongoDB server version is 4.0.0
php artisan queue:failed A cell must be a TableCell, a scalar or an object implementing __toString, array given.
php artisan queue:retry all Unable to find failed job with ID []. Unable to find failed job with ID []. Unable to find failed job with ID [].
I can provide exceptions as well if needed. Another interesting thing to note is that I'm using RabbitMQ for my queue (Only use MongoDB for failed jobs). And in my bootstrap/app.php (I should mention that I use Lumen as well), I have the following:
$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class); $app->register(Jenssegers\Mongodb\MongodbQueueServiceProvider::class); $app->register(VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider::class);
$app->withEloquent();
If I put the RabbitMQ ServiceProvider before the other two, then RabbitMQ stops working in Lumen. Not sure if I need the MongodbQueueServiceProvider to make the failed jobs work though. Currently it can add failed jobs, but not process them.
Since I have to release soon, I will go back to MySQL temporarily, but would very much appreciate help with this issue. I'll provide help if necessary to fix this bug.
did you find any solution to this i have the same problem
We have same issue with Laravel 5.8 & jenssegers/mongodb 3.5.1.
I'm seeing the same issue, this is with the custom service provider in place. The full stack trace is:
[2019-07-22 23:43:34] local.ERROR: A cell must be a TableCell, a scalar or an object implementing __toString, array given. {"exception":"[object] (Symfony\\Component\\Console\\Exception\\InvalidArgumentException(code: 0): A cell must be a TableCell, a scalar or an object implementing __toString, array given. at /usr/src/app/vendor/symfony/console/Helper/Table.php:581)
[stacktrace]
#0 /usr/src/app/vendor/symfony/console/Helper/Table.php(521): Symfony\\Component\\Console\\Helper\\Table->fillNextRows(Array, 2)
#1 /usr/src/app/vendor/symfony/console/Helper/Table.php(345): Symfony\\Component\\Console\\Helper\\Table->buildTableRows(Array)
#2 /usr/src/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(417): Symfony\\Component\\Console\\Helper\\Table->render()
#3 /usr/src/app/vendor/laravel/framework/src/Illuminate/Queue/Console/ListFailedCommand.php(116): Illuminate\\Console\\Command->table(Array, Array)
#4 /usr/src/app/vendor/laravel/framework/src/Illuminate/Queue/Console/ListFailedCommand.php(42): Illuminate\\Queue\\Console\\ListFailedCommand->displayFailedJobs(Array)
#5 [internal function]: Illuminate\\Queue\\Console\\ListFailedCommand->handle()
#6 /usr/src/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#7 /usr/src/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#8 /usr/src/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#9 /usr/src/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#10 /usr/src/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array)
#11 /usr/src/app/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#12 /usr/src/app/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#13 /usr/src/app/vendor/symfony/console/Application.php(901): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#14 /usr/src/app/vendor/symfony/console/Application.php(262): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\ListFailedCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#15 /usr/src/app/vendor/symfony/console/Application.php(145): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#16 /usr/src/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#17 /usr/src/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#18 /usr/src/app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#19 {main}
"}
Using Laravel 5.7
Exploring this a bit more. This may be because we had failed jobs lodged before we had implemented the custom service provider. We'll try clearing our existing failed jobs and see if new failed jobs that have been lodged with the custom service provider are able to be replayed. If so, I'll report back and I think you'll be able to close this ticket.
@Rodeoclash I think the issue is because failed_at in mongo is not anymore a timestamp, but a carbon object: "failed_at" : { "date" : "2019-08-02 14:59:39.645173", "timezone_type" : 3, "timezone" : "UTC" } When he should be timestamp : "failed_at" : 1548428034
In laravel it works like a charm, but not in Lumen, I think the problem would start from here vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php Because the MongoFailedJobProvider@log save as timestamp the failed_at date, only the mysql [(else) from MongodbQueueServiceProvider@registerFailedJobServices] is saving him as Carbon
Experiencing the same issue here with Lumen 6.0 and jenssegers/mongodb 3.6
@ionutraducanu is correct, this is due to the failed_at timestamp.
It is probably better to resolve this by changing how we are saving the failed_at field, but I was able to patch the commands for now by implementing a custom MongoFailedJobProvider which overrides the all() method.
I can confirm after implementing this, all artisan queue commands work as expected.
class MongoFailedJobProvider extends \Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider
{
/**
* Get a list of all of the failed jobs.
* @return object[]
*/
public function all()
{
$all = $this->getTable()->orderBy('_id', 'desc')->get()->all();
$all = array_map(function ($job) {
$job['id'] = (string)$job['_id'];
if (isset($job['failed_at']) && isset($job['failed_at']['date'])) {
$job['failed_at'] = Carbon::parse($job['failed_at']['date'])->toDateTimeString();
}
return (object)$job;
}, $all);
return $all;
}
}
The problem occurs because of the way lumen loads service providers, it is necessary to assemble the queue before registering MongodbQueueServiceProvider. This works in a similar way to using email queues in the lumen where we should do the following:
$app->make('queue');
$app->configure('mail');
$app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
I got the solution to this issue, would you still like it posted? If yes, please answer this issue and I will send here the necessary files for change and I will open a pull request to add the solution in the repo.
I am experiencing this on Laravel 8,
I've just come across this with Laravel 11. A quick workaround is to jump in to artisan tinker and run:
DB::table('failed_jobs')->pluck('_id')->each(fn ($item) => Artisan::call('queue:retry', ['id' => (string)$item]))->count();
This will push all the failed jobs back into the queue. Not ideal, but it works!
I've an open PR to fix this issue: https://github.com/mongodb/laravel-mongodb/pull/2838
Fixed by #2838 (to be released in 4.3)
Nice work @GromNaN ! Thanks
"jenssegers/mongodb": "^3.4"
artisan queue:retry all Does not find any failed jobs even when there are some present. Error: No failed job matches the given ID [].