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

randomly receive Invalid catalog name: 1046 No database selected (Connection: mysql, SQL: insert into failed_jobs (uuid, connection, queue, payload, exception, failed_at) on queue sqs #506

Closed
MattWiseParking opened this issue Dec 19, 2023 · 5 comments

Comments

@MattWiseParking
Copy link

I am randomly receiving the following errors in my log:

Message: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected (Connection: mysql, SQL: insert into failed_jobs (uuid, connection, queue, payload, exception, failed_at) values (64aefe2d-1c96-43c8-b872-cf595ac8b2c5, sqs,my-sqs-queue.fifo

@MattWiseParking
Copy link
Author

I think its because that my .env file database_connection is set to database_name rather than landlord, and that the multitenancy.php config file is tenant_database_connection_name value is set to NULL. Changing .env database_connection to landlord and updating tenant_database_connection_name value to 'tenant' to check

@MattWiseParking
Copy link
Author

i am sending to a fifo queue

Connection Name: Exception: PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected in /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php:416 Stack trace: #0 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(416): PDO->prepare('select * from ...') #1 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(788): Illuminate\Database\Connection->Illuminate\Database\{closure}('select * from ...', Array) #2 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(934): Illuminate\Database\Connection->runQueryCallback('select * from ...', Array, Object(Closure)) #3 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(914): Illuminate\Database\Connection->tryAgainIfCausedByLostConnection(Object(Illuminate\Database\QueryException), 'select * from ...', Array, Object(Closure)) #4 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(758): Illuminate\Database\Connection->handleQueryException(Object(Illuminate\Database\QueryException), 'select * from ...', Array, Object(Closure)) #5 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(424): Illuminate\Database\Connection->run('select * from ...', Array, Object(Closure)) #6 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2736): Illuminate\Database\Connection->select('select * from ...', Array, true) #7 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2724): Illuminate\Database\Query\Builder->runSelect() #8 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3278): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}() #9 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2725): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure)) #10 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(717): Illuminate\Database\Query\Builder->get(Array) #11 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(701): Illuminate\Database\Eloquent\Builder->getModels(Array) #12 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(296): Illuminate\Database\Eloquent\Builder->get(Array) #13 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(443): Illuminate\Database\Eloquent\Builder->first(Array) #14 /var/app/current/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\Database\Eloquent\Builder->find(3) #15 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2335): Illuminate\Database\Eloquent\Model->forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), 'find', Array) #16 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2347): Illuminate\Database\Eloquent\Model->__call('find', Array) #17 /var/app/current/vendor/spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php(105): Illuminate\Database\Eloquent\Model::__callStatic('find', Array) #18 /var/app/current/vendor/spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php(132): Spatie\Multitenancy\Actions\MakeQueueTenantAwareAction->findTenant(Object(Illuminate\Queue\Events\JobProcessing)) #19 /var/app/current/vendor/spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php(46): Spatie\Multitenancy\Actions\MakeQueueTenantAwareAction->bindOrForgetCurrentTenant(Object(Illuminate\Queue\Events\JobProcessing)) #20 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(421): Spatie\Multitenancy\Actions\MakeQueueTenantAwareAction->Spatie\Multitenancy\Actions{closure}(Object(Illuminate\Queue\Events\JobProcessing)) #21 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher->Illuminate\Events{closure}('Illuminate\Queu...', Array) #22 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(653): Illuminate\Events\Dispatcher->dispatch('Illuminate\Queu...') #23 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(426): Illuminate\Queue\Worker->raiseBeforeJobEvent('sqs', Object(Illuminate\Queue\Jobs\SqsJob)) #24 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(389): Illuminate\Queue\Worker->process('sqs', Object(Illuminate\Queue\Jobs\SqsJob), Object(Illuminate\Queue\WorkerOptions)) #25 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(176): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\SqsJob), 'sqs', Object(Illuminate\Queue\WorkerOptions)) #26 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(138): Illuminate\Queue\Worker->daemon('sqs', 'mycarpass.fifo', Object(Illuminate\Queue\WorkerOptions)) #27 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(121): Illuminate\Queue\Console\WorkCommand->runWorker('sqs', 'mycarpass.fifo') #28 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle() #29 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container{closure}() #30 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure)) #31 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #32 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #33 /var/app/current/vendor/laravel/framework/src/Illuminate/Console/Command.php(208): Illuminate\Container\Container->call(Array) #34 /var/app/current/vendor/symfony/console/Command/Command.php(326): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #35 /var/app/current/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #36 /var/app/current/vendor/symfony/console/Application.php(1081): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #37 /var/app/current/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #38 /var/app/current/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #39 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(200): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #40 /var/app/current/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #41 {main}

Next Illuminate\Database\QueryException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected (Connection: landlord, SQL: select * from tenants where tenants.id = 3 limit 1) in /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php:795 Stack trace: #0 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(934): Illuminate\Database\Connection->runQueryCallback('select * from ...', Array, Object(Closure)) #1 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(914): Illuminate\Database\Connection->tryAgainIfCausedByLostConnection(Object(Illuminate\Database\QueryException), 'select * from ...', Array, Object(Closure)) #2 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(758): Illuminate\Database\Connection->handleQueryException(Object(Illuminate\Database\QueryException), 'select * from ...', Array, Object(Closure)) #3 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(424): Illuminate\Database\Connection->run('select * from ...', Array, Object(Closure)) #4 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2736): Illuminate\Database\Connection->select('select * from ...', Array, true) #5 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2724): Illuminate\Database\Query\Builder->runSelect() #6 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3278): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}() #7 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2725): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure)) #8 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(717): Illuminate\Database\Query\Builder->get(Array) #9 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(701): Illuminate\Database\Eloquent\Builder->getModels(Array) #10 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(296): Illuminate\Database\Eloquent\Builder->get(Array) #11 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(443): Illuminate\Database\Eloquent\Builder->first(Array) #12 /var/app/current/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\Database\Eloquent\Builder->find(3) #13 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2335): Illuminate\Database\Eloquent\Model->forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), 'find', Array) #14 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2347): Illuminate\Database\Eloquent\Model->__call('find', Array) #15 /var/app/current/vendor/spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php(105): Illuminate\Database\Eloquent\Model::__callStatic('find', Array) #16 /var/app/current/vendor/spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php(132): Spatie\Multitenancy\Actions\MakeQueueTenantAwareAction->findTenant(Object(Illuminate\Queue\Events\JobProcessing)) #17 /var/app/current/vendor/spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php(46): Spatie\Multitenancy\Actions\MakeQueueTenantAwareAction->bindOrForgetCurrentTenant(Object(Illuminate\Queue\Events\JobProcessing)) #18 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(421): Spatie\Multitenancy\Actions\MakeQueueTenantAwareAction->Spatie\Multitenancy\Actions{closure}(Object(Illuminate\Queue\Events\JobProcessing)) #19 /var/app/current/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher->Illuminate\Events{closure}('Illuminate\Queu...', Array) #20 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(653): Illuminate\Events\Dispatcher->dispatch('Illuminate\Queu...') #21 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(426): Illuminate\Queue\Worker->raiseBeforeJobEvent('sqs', Object(Illuminate\Queue\Jobs\SqsJob)) #22 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(389): Illuminate\Queue\Worker->process('sqs', Object(Illuminate\Queue\Jobs\SqsJob), Object(Illuminate\Queue\WorkerOptions)) #23 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(176): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\SqsJob), 'sqs', Object(Illuminate\Queue\WorkerOptions)) #24 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(138): Illuminate\Queue\Worker->daemon('sqs', 'mycarpass.fifo', Object(Illuminate\Queue\WorkerOptions)) #25 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(121): Illuminate\Queue\Console\WorkCommand->runWorker('sqs', 'mycarpass.fifo') #26 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle() #27 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container{closure}() #28 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure)) #29 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #30 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #31 /var/app/current/vendor/laravel/framework/src/Illuminate/Console/Command.php(208): Illuminate\Container\Container->call(Array) #32 /var/app/current/vendor/symfony/console/Command/Command.php(326): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #33 /var/app/current/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) #34 /var/app/current/vendor/symfony/console/Application.php(1081): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #35 /var/app/current/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #36 /var/app/current/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #37 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(200): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #38 /var/app/current/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #39 {main}

@MattWiseParking
Copy link
Author

looks like theres an issue with supervisor loosing connection to the database, restarting supervisor seems to fix the issue and prevent this error from occurring

@MattWiseParking
Copy link
Author

but also an issue with jobs failing and not knowing where the failed table is: my code is in the queue:

'failed' => [
        'driver' => 'database-uuids',
        'database' => 'landlord',
        'table' => 'failed_jobs',
    ],

which is the root of the issue from the above error.

@spatie spatie locked as too heated and limited conversation to collaborators Jan 12, 2024
@masterix21
Copy link
Collaborator

Duplicated #505

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

No branches or pull requests

2 participants