From d177e3adfc940e86acbd4e10c4e0f1d1736aad8f Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 18 Mar 2026 10:06:53 +0530 Subject: [PATCH] fix pool issue --- app/init/registers.php | 15 ++------------- docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/app/init/registers.php b/app/init/registers.php index 7b68c2af9a..ab24c847a6 100644 --- a/app/init/registers.php +++ b/app/init/registers.php @@ -217,19 +217,8 @@ $register->set('pools', function () { $maxConnections = System::getEnv('_APP_CONNECTIONS_MAX', 151); $instanceConnections = $maxConnections / System::getEnv('_APP_POOL_CLIENTS', 14); - $multiprocessing = System::getEnv('_APP_SERVER_MULTIPROCESS', 'disabled') === 'enabled'; - - if ($multiprocessing) { - $workerCount = intval(System::getEnv('_APP_CPU_NUM', swoole_cpu_num())) * intval(System::getEnv('_APP_WORKER_PER_CORE', 6)); - } else { - $workerCount = 1; - } - - if ($workerCount > $instanceConnections) { - throw new \Exception('Pool size is too small. Increase the number of allowed database connections or decrease the number of workers.', 500); - } - - $poolSize = (int)($instanceConnections / $workerCount); + $workerCount = intval(System::getEnv('_APP_CPU_NUM', swoole_cpu_num())) * intval(System::getEnv('_APP_WORKER_PER_CORE', 6)); + $poolSize = max(1, (int)($instanceConnections / $workerCount)); foreach ($connections as $key => $connection) { $type = $connection['type'] ?? ''; diff --git a/docker-compose.yml b/docker-compose.yml index 7d64dfa867..e93146c779 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1244,7 +1244,7 @@ services: - MYSQL_USER=${_APP_DB_USER} - MYSQL_PASSWORD=${_APP_DB_PASS} - MARIADB_AUTO_UPGRADE=1 - command: "mysqld --innodb-flush-method=fsync" + command: "mysqld --innodb-flush-method=fsync --max-connections=500" healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 5s @@ -1308,7 +1308,7 @@ services: - POSTGRES_DB=${_APP_DB_SCHEMA} - POSTGRES_USER=${_APP_DB_USER} - POSTGRES_PASSWORD=${_APP_DB_PASS} - command: "postgres" + command: "postgres -N 500" healthcheck: test: ["CMD-SHELL", "pg_isready -U ${_APP_DB_USER}"] interval: 5s