部署了一个服务,大致流程是客户端请求服务端,服务端用swoole协程同时curl请求多个三方API,经过一些业务处理返回数据给客户端(优先返回“请求速度更快、并且在业务上处于更高优先级的api”的响应结果)
在workerman.log和stdout.log会出现标题所示的错误
public static function getInfo(string $request_data)
{
$thirds = Third::cases();
$count = count($thirds);
$channel = new Channel($count);
foreach ($thirds as $third) {
Coroutine::create(function () use ($channel, $third, $request_data) {
$class_name = $third->className();
$option = call_user_func([$class_name, Third::FUNC_GET_OPTION], $request_data);
try {
$response = Curl::post($option['url'], $option['data'], $option['header'], 3000);
} catch (Throwable $exception) {
$response = '';
}
$result = call_user_func([$class_name, Third::FUNC_GET_RESULT], $response);
$channel->push([
'third' => $third,
'result' => $result,
]);
});
}
return self::orderThirdResult($count, $channel);
}
private static function orderThirdResult(int $count, Channel $channel)
{
$list = [];
$order_scheme = self::ORDER_SCHEME;
for ($i = 0; $i < $count; $i++) {
$item = $channel->pop();
$list[$item['third']->value] = $item;
foreach ($order_scheme as $thirds) {
$is_this_order_finish = true;
foreach ($thirds as $third) {
if (!isset($list[$third->value])) {
$is_this_order_finish = false;
} else if ($list[$third->value]['result']) {
return $list[$third->value];
}
}
if (!$is_this_order_finish) {
break;
}
}
}
return ['third' => null, 'result' => ''];
}
2025-12-15 17:04:25 pid:3086 Worker[3086] process terminated with ERROR: E_ERROR "Uncaught RuntimeException: Failed to get a connection from the pool within the wait timeout (3 seconds). The connection pool is exhausted. in /www/wwwroot/privacy/vendor/workerman/coroutine/src/Pool.php:193
2025-12-15 17:04:25 pid:28912 worker[coroutine:3086] exit with status 6
2025-12-15 17:04:29 pid:3021 Worker[3021] process terminated with ERROR: E_ERROR "Uncaught RuntimeException: Failed to get a connection from the pool within the wait timeout (3 seconds). The connection pool is exhausted. in /www/wwwroot/privacy/vendor/workerman/coroutine/src/Pool.php:193
2025-12-15 17:04:29 pid:28912 worker[coroutine:3021] exit with status 6
2025-12-15 17:04:49 pid:3119 Worker[3119] process terminated with ERROR: E_ERROR "Uncaught RuntimeException: Failed to get a connection from the pool within the wait timeout (3 seconds). The connection pool is exhausted. in /www/wwwroot/privacy/vendor/workerman/coroutine/src/Pool.php:193
2025-12-15 17:04:49 pid:28912 worker[coroutine:3119] exit with status 11
2025-12-15 17:05:00 pid:3131 Worker[3131] process terminated with ERROR: E_ERROR "Uncaught RuntimeException: Failed to get a connection from the pool within the wait timeout (3 seconds). The connection pool is exhausted. in /www/wwwroot/privacy/vendor/workerman/coroutine/src/Pool.php:193
2025-12-15 17:05:00 pid:28912 worker[coroutine:3131] exit with status 6
[2025-12-15 17:04:25 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 20 consumers will be discarded
[2025-12-15 17:04:25 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 1 consumers will be discarded
[2025-12-15 17:04:25 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 1 consumers will be discarded
[2025-12-15 17:04:29 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 15 consumers will be discarded
[2025-12-15 17:04:29 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 1 consumers will be discarded
[2025-12-15 17:04:29 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 1 consumers will be discarded
[2025-12-15 17:04:29 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 1 consumers will be discarded
[2025-12-15 17:04:29 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 1 consumers will be discarded
[2025-12-15 17:04:49 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 20 consumers will be discarded
[2025-12-15 17:05:00 @28891.0] WARNING Channel::~Channel() (ERRNO 10003): channel is destroyed, 10 consumers will be discarded



连接池配置太小:你的数据库连接池最大连接数设置得太低了,比如只配置了2个,但实际业务需要更多连接
慢查询问题:有SQL执行时间太长,占用了连接但没及时释放
连接泄漏:代码中获取了连接但没有正确关闭(比如没在finally块中关闭连接)
升级一下swoole的版本或者编译swoole的时候开启--enable-swoole-curl