Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel queue doesn't work with queue connection database. #2629

Open
spont4e opened this issue Sep 25, 2023 · 8 comments
Open

Laravel queue doesn't work with queue connection database. #2629

spont4e opened this issue Sep 25, 2023 · 8 comments

Comments

@spont4e
Copy link

spont4e commented Sep 25, 2023

  • 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+020230907.41+debian111.gbp9ffec5
  • php8.2-mongodb / 1.16.2-1+020230907.41+debian111.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}
"} 
@GromNaN
Copy link
Member

GromNaN commented Sep 25, 2023

Do you know if it worked with Laravel 9 and laravel-mongodb 3.9? I'd like to determine whether it's a regression or a new feature or a need for documentation.

@spont4e
Copy link
Author

spont4e commented Sep 25, 2023

@GromNaN I don't know...
But I can test it

@spont4e
Copy link
Author

spont4e commented Sep 25, 2023

@GromNaN Same problem here

  • Laravel Version: 9.52.15
  • Laravel-mongodb Version: v3.9.5
  • PHP Version: 8.0.30
  • Database Driver & Version: MongoDB driver for PHP
  • php8.0-mongodb / 1.16.2-1+020230907.41+debian111.gbp9ffec5
Logs:
[2023-09-25 19:29: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/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php:258)
[stacktrace]
#0 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(239): Illuminate\\Queue\\DatabaseQueue->getLockForPopping()
#1 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(224): Illuminate\\Queue\\DatabaseQueue->getNextAvailableJob()
#2 /var/www/tmp/laravel/vendor/mongodb/laravel-mongodb/src/Concerns/ManagesTransactions.php(102): Illuminate\\Queue\\DatabaseQueue->Illuminate\\Queue\\{closure}()
#3 /var/www/tmp/laravel/vendor/mongodb/mongodb/src/Operation/WithTransaction.php(64): Jenssegers\\Mongodb\\Connection->Jenssegers\\Mongodb\\Concerns\\{closure}()
#4 /var/www/tmp/laravel/vendor/mongodb/mongodb/src/functions.php(496): MongoDB\\Operation\\WithTransaction->execute()
#5 /var/www/tmp/laravel/vendor/mongodb/laravel-mongodb/src/Concerns/ManagesTransactions.php(108): MongoDB\\with_transaction()
#6 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(227): Jenssegers\\Mongodb\\Connection->transaction()
#7 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(342): Illuminate\\Queue\\DatabaseQueue->pop()
#8 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(351): Illuminate\\Queue\\Worker->Illuminate\\Queue\\{closure}()
#9 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(160): Illuminate\\Queue\\Worker->getNextJob()
#10 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(148): Illuminate\\Queue\\Worker->daemon()
#11 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(131): Illuminate\\Queue\\Console\\WorkCommand->runWorker()
#12 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle()
#13 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#14 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#15 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#16 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(661): Illuminate\\Container\\BoundMethod::call()
#17 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call()
#18 /var/www/tmp/laravel/vendor/symfony/console/Command/Command.php(291): Illuminate\\Console\\Command->execute()
#19 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(153): Symfony\\Component\\Console\\Command\\Command->run()
#20 /var/www/tmp/laravel/vendor/symfony/console/Application.php(1014): Illuminate\\Console\\Command->run()
#21 /var/www/tmp/laravel/vendor/symfony/console/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand()
#22 /var/www/tmp/laravel/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun()
#23 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\\Component\\Console\\Application->run()
#24 /var/www/tmp/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(155): Illuminate\\Console\\Application->run()
#25 /var/www/tmp/laravel/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#26 {main}
"} 

@GromNaN
Copy link
Member

GromNaN commented Nov 9, 2023

Tracked in PHPORM-87 (duplicated in PHPORM-97)

@devjeet073
Copy link

@spont4e
Have you checked file "config/queue.php".

Make sure in "connections"->"database"->["driver"=> "mongodb"].

@spont4e
Copy link
Author

spont4e commented Feb 15, 2024

@spont4e Have you checked file "config/queue.php".

Make sure in "connections"->"database"->["driver"=> "mongodb"].

Yes, Everything was configured properly.

@Nemutagk
Copy link

is there any new news about this, we are already in laravel 11 and the error still persists when the default connection is MongoDB.

@bisht2050
Copy link
Contributor

We tentatively plan to work on this in the next month (April 2024).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants