This commit is contained in:
2021-07-05 16:31:35 +08:00
parent 2ea7289c43
commit 3345ff697b
2 changed files with 7 additions and 3 deletions
+5 -2
View File
@@ -194,6 +194,9 @@ class Connection extends Component
if (empty($this->slaveConfig) || Db::transactionsActive()) {
return $this->masterInstance();
}
if ($this->slaveConfig['cds'] == $this->cds) {
return $this->masterInstance();
}
return $this->connections()->get($this->slaveConfig, false);
}
@@ -298,9 +301,9 @@ class Connection extends Component
/**
* @param $dbname
* @param $sql
* @return array|string|string[]|null
* @return array|string|null
*/
private function selectMatch($dbname, $sql)
private function selectMatch($dbname, $sql): array|string|null
{
return preg_replace('/FROM\s+(\w+)\s+/', 'FROM `' . $dbname . '`.$1 ', $sql);
}
+2 -1
View File
@@ -92,7 +92,8 @@ class ClientsPool extends Component
$this->flush($channel, $min);
}
$num[$key] += $channel->length();
if (str_starts_with($key, 'Mysql') && (Snowflake::isWorker() || Snowflake::isTask())) {
if (str_starts_with($key, 'Mysql') && (Snowflake::isWorker() || Snowflake::isTask())
&& $channel->length() > 0) {
$this->debug('Worker #' . env('worker') . ' use client -> ' . $key . ':' . $total);
}
$total += $channel->length();