Merge remote-tracking branch 'origin/master'

This commit is contained in:
ASUS 2025-08-16 09:02:55 +08:00
commit 27dab0a399
3 changed files with 72 additions and 89 deletions

View File

@ -83,14 +83,6 @@ class DbCoroutineContext
public static function clearList()
{
foreach (self::getList() as $conn) {
try {
$conn->query('SELECT 1');
$conn->close();
// 连接正常
} catch (\Exception $e) {
}
}
$cid = self::getCid();
if ($cid !== null) {
unset(self::$list[$cid]);
@ -112,7 +104,6 @@ class DbCoroutineContext
foreach (self::getList() as $conn) {
try {
$conn->query('SELECT 1');
$conn->close();
// 连接正常
} catch (\Exception $e) {
}

View File

@ -161,7 +161,6 @@ class DatabaseRoute
->page($currPage, $pageSize)
->select()
->toArray();
$query->getConnection()->close();
return [
'totalCount' => $totalCount,
@ -204,7 +203,6 @@ class DatabaseRoute
// 不要order避免报错
$query->removeOption('order');
$count = $query->count();
$query->getConnection()->close();
$counts[$connName] = $count;
$total += $count;
}
@ -258,7 +256,6 @@ class DatabaseRoute
->limit($localOffset, $localLimit)
->select()
->toArray();
$query->getConnection()->close();
$allRows = array_merge($allRows, $rows);
@ -375,7 +372,6 @@ class DatabaseRoute
$query = Db::connect($connName)->name($table);
$query = call_user_func($builder, $query);
$deleted = $query->delete();
$query->getConnection()->close();
$totalDeleted += $deleted;
}
@ -415,13 +411,11 @@ class DatabaseRoute
if (method_exists($query, $method)) {
$result = call_user_func_array([$query, $method], $args);
$finalResult = $result;
$query->getConnection()->close();
// find 返回 nullselect 返回空数组count 返回数字
if ($result || $result === 0) {
return $result;
}
}else {
$query->getConnection()->close();
}
}
}
@ -436,7 +430,6 @@ class DatabaseRoute
$result = call_user_func_array([$query, $method], $args);
// find 返回 nullselect 返回空数组count 返回数字
$finalResult = $result;
$query->getConnection()->close();
if ($result instanceof Collection) {
if (!$result->isEmpty()) {
return $result;
@ -447,7 +440,6 @@ class DatabaseRoute
return $result;
}
}else {
$query->getConnection()->close();
}
}
}

View File

@ -31,8 +31,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -66,8 +66,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -101,8 +101,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -137,8 +137,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -172,8 +172,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -207,8 +207,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -243,8 +243,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -282,8 +282,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -318,8 +318,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -354,8 +354,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -390,8 +390,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -425,8 +425,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -460,8 +460,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -495,8 +495,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -530,8 +530,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -565,8 +565,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -600,8 +600,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -635,8 +635,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -670,8 +670,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -705,8 +705,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -740,8 +740,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -775,8 +775,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -810,8 +810,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -845,8 +845,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -880,8 +880,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -915,8 +915,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -950,8 +950,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -985,8 +985,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1020,8 +1020,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1055,8 +1055,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1091,8 +1091,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1127,8 +1127,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1163,8 +1163,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1198,8 +1198,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1234,8 +1234,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒
@ -1269,8 +1269,8 @@ return [
'bootstrap' => '',
// 连接池配置
'pool' => [
'max_connections' => 500, // 最大连接数
'min_connections' => 20, // 最小连接数
'max_connections' => 100, // 最大连接数
'min_connections' => 10, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
'heartbeat_interval' => 50, // 心跳检测间隔需要小于60秒