laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Laravel queue doesn't work with queue connection database.

Open spont4e opened this issue 9 months ago • 8 comments

  • Laravel-mongodb Version: 4.0.0-rc1
  • Laravel Version: 10.24.0
  • PHP Version: 8.1.17 | 8.2.10
  • Database Driver & Version: MongoDB driver for PHP
  • php8.1-mongodb / 1.16.2-1+0~20230907.41+debian11~1.gbp9ffec5
  • php8.2-mongodb / 1.16.2-1+0~20230907.41+debian11~1.gbp9ffec5

Description:

Laravel queue doesn't work when mongodb is the default database driver.

Steps to reproduce

  1. Setup Laravel 10.24.0
  2. Setup mongodb/laravel-mongodb:4.0.0-rc1
  3. Change .env > DB_CONNECTION=mongodb
  4. Change .env > QUEUE_CONNECTION=database
  5. Run php8.2 artisan queue:work --queue=high,default,low --sleep=3 --tries=3 --daemon

Expected behaviour

storage/logs/laravel.log to be clean.

Actual behaviour

storage/logs/laravel.log contains error.

[2023-09-25 13:24:51] local.ERROR: Call to a member function getAttribute() on null {"exception":"[object] (Error(code: 0): Call to a member function getAttribute() on null at /var/www/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php:258)
Logs:
[2023-09-25 13:24:51] local.ERROR: Call to a member function getAttribute() on null {"exception":"[object] (Error(code: 0): Call to a member function getAttribute() on null at /var/www/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php:258)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(239): Illuminate\\Queue\\DatabaseQueue->getLockForPopping()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(224): Illuminate\\Queue\\DatabaseQueue->getNextAvailableJob()
#2 /var/www/vendor/mongodb/laravel-mongodb/src/Concerns/ManagesTransactions.php(101): Illuminate\\Queue\\DatabaseQueue->Illuminate\\Queue\\{closure}()
#3 /var/www/vendor/mongodb/mongodb/src/Operation/WithTransaction.php(64): MongoDB\\Laravel\\Connection->MongoDB\\Laravel\\Concerns\\{closure}()
#4 /var/www/vendor/mongodb/mongodb/src/functions.php(496): MongoDB\\Operation\\WithTransaction->execute()
#5 /var/www/vendor/mongodb/laravel-mongodb/src/Concerns/ManagesTransactions.php(107): MongoDB\\with_transaction()
#6 /var/www/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(227): MongoDB\\Laravel\\Connection->transaction()
#7 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(349): Illuminate\\Queue\\DatabaseQueue->pop()
#8 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(363): Illuminate\\Queue\\Worker->Illuminate\\Queue\\{closure}()
#9 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(163): Illuminate\\Queue\\Worker->getNextJob()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(138): Illuminate\\Queue\\Worker->daemon()
#11 /var/www/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(121): Illuminate\\Queue\\Console\\WorkCommand->runWorker()
#12 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle()
#13 /var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#14 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#15 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#16 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call()
#17 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call()
#18 /var/www/vendor/symfony/console/Command/Command.php(326): Illuminate\\Console\\Command->execute()
#19 /var/www/vendor/laravel/framework/src/Illuminate/Console/Command.php(181): Symfony\\Component\\Console\\Command\\Command->run()
#20 /var/www/vendor/symfony/console/Application.php(1081): Illuminate\\Console\\Command->run()
#21 /var/www/vendor/symfony/console/Application.php(320): Symfony\\Component\\Console\\Application->doRunCommand()
#22 /var/www/vendor/symfony/console/Application.php(174): Symfony\\Component\\Console\\Application->doRun()
#23 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\\Component\\Console\\Application->run()
#24 /var/www/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#25 {main}
"} 

spont4e avatar Sep 25 '23 13:09 spont4e