This commit is contained in:
2021-07-05 16:52:53 +08:00
parent c075662c59
commit 4d2b462676
+13 -4
View File
@@ -80,6 +80,17 @@ class ClientsPool extends Component
Timer::clear($this->creates);
$this->creates = -1;
} else {
$this->heartbeat_flush();
}
}
/**
* @throws ConfigException
* @throws Exception
*/
private function heartbeat_flush()
{
$min = Config::get('databases.pool.min', 1);
$num = [];
@@ -88,11 +99,10 @@ class ClientsPool extends Component
if (!isset($num[$key])) {
$num[$key] = 0;
}
if ($channel->length() > $min) {
$length = $channel->length();
if ($length > $min) {
$this->flush($channel, $min);
}
$length = $channel->length();
$num[$key] += $length;
if (str_starts_with($key, 'Mysql') && (Snowflake::isWorker() || Snowflake::isTask()) && $length > 0) {
$this->debug('Worker #' . env('worker') . ' use client -> ' . $key . ':' . $length);
@@ -104,7 +114,6 @@ class ClientsPool extends Component
$this->creates = -1;
}
}
}
/**