定时出现Too many connections 重启后就好了但是会再次出现

test123321

问题描述

都是用Db:table 查询运行一段时候后查询报错Too many connections ,加了几个定时任务,cpu32个进程128个,改了这个进程数还是会出现Too many connections这种情况服务器提示499

程序代码

都是的用很简单的 Db:table 查询 orm操作

报错信息

[2023-06-10 10:26:33] default.ERROR: 10.2.5.7 GET 10.2.5.7:8787
PDOException: SQLSTATE[HY000] [1040] Too many connections in /www/wwwroot/qkl/vendor/illuminate/database/Connectors/Connector.php:70
Stack trace:
#0 /www/wwwroot/qkl/vendor/illuminate/database/Connectors/Connector.php(70): PDO->__construct()
#1 /www/wwwroot/qkl/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection()
#2 /www/wwwroot/qkl/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection()
#3 /www/wwwroot/qkl/vendor/illuminate/database/Connectors/ConnectionFactory.php(184): Illuminate\Database\Connectors\MySqlConnector->connect()
#4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#5 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(1064): call_user_func()
#6 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(1100): Illuminate\Database\Connection->getPdo()
#7 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(442): Illuminate\Database\Connection->getReadPdo()
#8 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(368): Illuminate\Database\Connection->getPdoForSelect()
#9 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(705): Illuminate\Database\Connection->Illuminate\Database\{closure}()
#10 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(672): Illuminate\Database\Connection->runQueryCallback()
#11 /www/wwwroot/qkl/vendor/illuminate/database/Connection.php(376): Illuminate\Database\Connection->run()
#12 /www/wwwroot/qkl/vendor/illuminate/database/Query/Builder.php(2414): Illuminate\Database\Connection->select()
#13 /www/wwwroot/qkl/vendor/illuminate/database/Query/Builder.php(2402): Illuminate\Database\Query\Builder->runSelect()
#14 /www/wwwroot/qkl/vendor/illuminate/database/Query/Builder.php(2936): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#15 /www/wwwroot/qkl/vendor/illuminate/database/Query/Builder.php(2403): Illuminate\Database\Query\Builder->onceWithColumns()
#16 /www/wwwroot/qkl/vendor/illuminate/database/Eloquent/Builder.php(625): Illuminate\Database\Query\Builder->get()
#17 /www/wwwroot/qkl/vendor/illuminate/database/Eloquent/Builder.php(609): Illuminate\Database\Eloquent\Builder->getModels()
#18 /www/wwwroot/qkl/vendor/illuminate/database/Concerns/BuildsQueries.php(294): Illuminate\Database\Eloquent\Builder->get()
#19 /www/wwwroot/qkl/app/controller/IndexController.php(43): Illuminate\Database\Eloquent\Builder->first()
#20 /www/wwwroot/qkl/vendor/workerman/webman-framework/src/App.php(319): app\controller\IndexController->index()
#21 /www/wwwroot/qkl/vendor/workerman/webman-framework/src/App.php(168): Webman\App::Webman\{closure}()
#22 /www/wwwroot/qkl/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\App->onMessage()
#23 [internal function]: Workerman\Connection\TcpConnection->baseRead()
#24 /www/wwwroot/qkl/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
#25 /www/wwwroot/qkl/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Event->loop()
#26 /www/wwwroot/qkl/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux()
#27 /www/wwwroot/qkl/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#28 /www/wwwroot/qkl/vendor/workerman/workerman/Worker.php(1779): Workerman\Worker::forkWorkers()
#29 /www/wwwroot/qkl/vendor/workerman/workerman/Worker.php(1715): Workerman\Worker::monitorWorkersForLinux()
#30 /www/wwwroot/qkl/vendor/workerman/workerman/Worker.php(562): Workerman\Worker::monitorWorkers()
#31 /www/wwwroot/qkl/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#32 /www/wwwroot/qkl/start.php(4): support\App::run()
#33 {main}

截图报错信息里报错文件相关代码

这里粘贴截图
截图

操作系统及workerman/webman等框架组件具体版本

webman最新版本1.4

953 1 1
1个回答

banro512

一个进程一个mysql连接,你128个进程,再加上计划任务里的连接,会更多。mysql默认连接限制100.超过就会报这个错误。
先去mysql里看看设置的最大连接数。

年代过于久远,无法发表回答
×
🔝