From 9190427ae2444102d82ed0d622617c54eb43fa74 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 15 Jan 2014 10:20:52 -0800 Subject: [PATCH] Fixed getReaderIndex() handling of $group * Connections for a group should not override the generic connection handle. That can cause special DBs to be reused for general queries more so than optimal. * Also made the code use ProfileSection to clean it up a bit. Change-Id: Ia8973133a93410bd906d8ad52a711a7d810df2f6 --- includes/db/LoadBalancer.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 7d0fe34872..c622afe8f5 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -203,7 +203,7 @@ class LoadBalancer { return $this->mReadIndex; } - wfProfileIn( __METHOD__ ); + $section = new ProfileSection( __METHOD__ ); # Find the relevant load array if ( $group !== false ) { @@ -212,7 +212,6 @@ class LoadBalancer { } else { # No loads for this group, return false and the caller can use some other group wfDebug( __METHOD__ . ": no loads for group $group\n" ); - wfProfileOut( __METHOD__ ); return false; } @@ -221,7 +220,6 @@ class LoadBalancer { } if ( !count( $nonErrorLoads ) ) { - wfProfileOut( __METHOD__ ); throw new MWException( "Empty server array given to LoadBalancer" ); } @@ -255,7 +253,6 @@ class LoadBalancer { # This is permanent and means the configuration or the load monitor # wants us to return false. wfDebugLog( 'connect', __METHOD__ . ": pickRandom() returned false\n" ); - wfProfileOut( __METHOD__ ); return false; } @@ -294,11 +291,10 @@ class LoadBalancer { $this->mServers[$i]['slave pos'] = $conn->getSlavePos(); } } - if ( $this->mReadIndex <= 0 && $this->mLoads[$i] > 0 && $i !== false ) { + if ( $this->mReadIndex <= 0 && $this->mLoads[$i] > 0 && $group !== false ) { $this->mReadIndex = $i; } } - wfProfileOut( __METHOD__ ); return $i; } -- 2.20.1