From 5c21483236a59ed0f397cddae9f59f0d1b719239 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 25 Jun 2005 13:48:02 +0000 Subject: [PATCH] fixed repeated balancing bug --- includes/LoadBalancer.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index a60d28476b..ee402d68e5 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -145,7 +145,13 @@ class LoadBalancer { return $this->pickRandom( $loads ); } - + /** + * Get the index of the reader connection, which may be a slave + * This takes into account load ratios and lag times. It should + * always return a consistent index during a given invocation + * + * Side effect: opens connections to databases + */ function getReaderIndex() { global $wgMaxLag, $wgReadOnly, $wgDBClusterTimeout; @@ -215,7 +221,7 @@ class LoadBalancer { $this->mServers[$i]['slave pos'] = $this->mConnections[$i]->getSlavePos(); } } - if ( $i != false ) { + if ( $i !== false ) { $this->mReadIndex = $i; } } else { -- 2.20.1