From: Aaron Schulz Date: Fri, 13 Mar 2015 01:50:05 +0000 (-0700) Subject: Avoid certain useless dbperformance log entries X-Git-Tag: 1.31.0-rc.0~12107^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=a00be92e998003779951a2e5f1960d3178ba8371;p=lhc%2Fweb%2Fwiklou.git Avoid certain useless dbperformance log entries * If DB_SLAVE was used but a master was picked due to having non-zero load, that should not issue a warning. Change-Id: I79f3c477b4160b15ffb7f7679d7e15cabc236b82 --- diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index dd95844811..4e0a5b9cc3 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -471,6 +471,9 @@ class LoadBalancer { ? array( false ) // check one "group": the generic pool : (array)$groups; + $masterOnly = ( $i == DB_MASTER || $i == $this->getWriterIndex() ); + $oldConnsOpened = $this->connsOpened; // connections open now + if ( $i == DB_MASTER ) { $i = $this->getWriterIndex(); } else { @@ -506,6 +509,14 @@ class LoadBalancer { return $this->reportConnectionError(); } + # Profile any new connections that happen + if ( $this->connsOpened > $oldConnsOpened ) { + $host = $conn->getServer(); + $dbname = $conn->getDBname(); + $trxProf = Profiler::instance()->getTransactionProfiler(); + $trxProf->recordConnection( $host, $dbname, $masterOnly ); + } + return $conn; } @@ -756,10 +767,6 @@ class LoadBalancer { $db = $e->db; } - $isMaster = !empty( $server['master'] ); - $trxProf = Profiler::instance()->getTransactionProfiler(); - $trxProf->recordConnection( $server['host'], $server['dbname'], $isMaster ); - $db->setLBInfo( $server ); if ( isset( $server['fakeSlaveLag'] ) ) { $db->setFakeSlaveLag( $server['fakeSlaveLag'] );