codestudiohq / laravel-totem

Manage Your Laravel Schedule From A Web Dashboard
MIT License
1.8k stars 224 forks source link

SQLSTATE[HY000] [1040] Too many connections (SQL: select * from `task_frequencies` where `task_frequencies`.`task_id` = 2 and `task_frequencies`.`task_id` is not null) #184

Closed mailnike closed 5 years ago

mailnike commented 5 years ago

Hi,

I am getting below error (quite possible that it is not directly relevant to this package but posting here as this table is created by this package).

Any idea what could be the reason? We using Totem on Laravel 5.8 with Laravel Telescope and Horizon. Is it because telescope adds a lot of entries and deleting them degrades the performance or is it because of some package limitations?

`

SQLSTATE[HY000] [1040] Too many connections (SQL: select * from `task_frequencies` where `task_frequencies`.`task_id` = 2 and `task_frequencies`.`task_id` is not null)
#0 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure))
#2 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2130): Illuminate\Database\Connection->select('select * from `...', Array, true)
#3 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2118): Illuminate\Database\Query\Builder->runSelect()
#4 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2604): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#5 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2119): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#6 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(521): Illuminate\Database\Query\Builder->get(Array)
#7 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(505): Illuminate\Database\Eloquent\Builder->getModels(Array)
#8 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php(17): Illuminate\Database\Eloquent\Builder->get()
#9 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(425): Illuminate\Database\Eloquent\Relations\HasMany->getResults()
#10 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(397): Illuminate\Database\Eloquent\Model->getRelationshipFromMethod('frequencies')
#11 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(329): Illuminate\Database\Eloquent\Model->getRelationValue('frequencies')
#12 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1523): Illuminate\Database\Eloquent\Model->getAttribute('frequencies')
#13 /home/forge/account.zaperp.com/releases/11/vendor/studio/laravel-totem/src/Traits/HasFrequencies.php(104): Illuminate\Database\Eloquent\Model->__get('frequencies')
#14 /home/forge/account.zaperp.com/releases/11/vendor/studio/laravel-totem/src/Providers/ConsoleServiceProvider.php(36): Studio\Totem\Task->getCronExpression()
#15 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Support/Collection.php(475): Studio\Totem\Providers\ConsoleServiceProvider->Studio\Totem\Providers\{closure}(Object(Studio\Totem\Task), 1)
#16 /home/forge/account.zaperp.com/releases/11/vendor/studio/laravel-totem/src/Providers/ConsoleServiceProvider.php(56): Illuminate\Support\Collection->each(Object(Closure))
#17 /home/forge/account.zaperp.com/releases/11/vendor/studio/laravel-totem/src/Providers/ConsoleServiceProvider.php(20): Studio\Totem\Providers\ConsoleServiceProvider->schedule(Object(Illuminate\Console\Scheduling\Schedule))
#18 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Container/Container.php(1084): Studio\Totem\Providers\ConsoleServiceProvider->Studio\Totem\Providers\{closure}(Object(Illuminate\Console\Scheduling\Schedule), Object(Illuminate\Foundation\Application))
#19 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Container/Container.php(1030): Illuminate\Container\Container->fireCallbackArray(Object(Illuminate\Console\Scheduling\Schedule), Array)
#20 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Container/Container.php(687): Illuminate\Container\Container->fireResolvingCallbacks('Illuminate\\Cons...', Object(Illuminate\Console\Scheduling\Schedule))
#21 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('Illuminate\\Cons...', Array)
#22 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(767): Illuminate\Container\Container->make('Illuminate\\Cons...', Array)
#23 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(106): Illuminate\Foundation\Application->make('Illuminate\\Cons...')
#24 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(90): Illuminate\Foundation\Console\Kernel->defineConsoleSchedule()
#25 [internal function]: Illuminate\Foundation\Console\Kernel->Illuminate\Foundation\Console\{closure}(Object(Illuminate\Foundation\Application))
#26 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(866): call_user_func(Object(Closure), Object(Illuminate\Foundation\Application))
#27 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(815): Illuminate\Foundation\Application->fireAppCallbacks(Array)
#28 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#29 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(210): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#30 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(322): Illuminate\Foundation\Application->bootstrapWith(Array)
#31 /home/forge/account.zaperp.com/releases/11/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->bootstrap()
#32 /home/forge/account.zaperp.com/releases/11/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 {main}

`

Any help would be appreciated.

qschmick commented 5 years ago

@mailnike Sorry to hear you're having issues. This isn't a specific issue with Totem but potentially an issue with your DB setup or how your codebase is running. In general this issue highlights that you have too many connections already open to the database and this process attempted to open another.

You can fix this by increasing the max_connections setting within MySQL.

Some resources