From: jenkins-bot Date: Fri, 11 Jul 2014 18:02:10 +0000 (+0000) Subject: Merge "Made getMaxLag() use caching to reduce connection spam" X-Git-Tag: 1.31.0-rc.0~14993 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=b3c307518a8dfd8a38267e17edbc8342822c2f45;p=lhc%2Fweb%2Fwiklou.git Merge "Made getMaxLag() use caching to reduce connection spam" --- b3c307518a8dfd8a38267e17edbc8342822c2f45 diff --cc includes/db/LoadBalancer.php index 0c4188ceda,7e9c08cd69..53532880d1 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@@ -1048,11 -1048,19 +1048,22 @@@ class LoadBalancer $maxLag = -1; $host = ''; $maxIndex = 0; - if ( $this->getServerCount() > 1 ) { // no replication = no lag + + if ( $this->getServerCount() <= 1 ) { // no replication = no lag + return array( $host, $maxLag, $maxIndex ); + } + + // Try to get the max lag info from the server cache + $key = 'loadbalancer:maxlag:cluster:' . $this->mServers[0]['host']; + $cache = ObjectCache::newAccelerator( array(), 'hash' ); + $maxLagInfo = $cache->get( $key ); // (host, lag, index) + + // Fallback to connecting to each slave and getting the lag + if ( !$maxLagInfo ) { foreach ( $this->mServers as $i => $conn ) { + if ( $i == $this->getWriterIndex() ) { + continue; // nothing to check + } $conn = false; if ( $wiki === false ) { $conn = $this->getAnyOpenConnection( $i );