From a00be92e998003779951a2e5f1960d3178ba8371 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 12 Mar 2015 18:50:05 -0700 Subject: [PATCH] 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 --- includes/db/LoadBalancer.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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'] ); -- 2.20.1