From: Aaron Schulz Date: Wed, 15 Jan 2014 18:20:52 +0000 (-0800) Subject: Fixed getReaderIndex() handling of $group X-Git-Tag: 1.31.0-rc.0~17066 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22config_fonctions%22%2C%20%22image_process=%24process%22%29%20.%20%22?a=commitdiff_plain;h=9190427ae2444102d82ed0d622617c54eb43fa74;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; }