From ea93933ee9198bc7f5b5dfa6836275bad4cc8974 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 18 Mar 2010 05:23:46 +0000 Subject: [PATCH] * Fixed complete breakage of "lag.php -r" due to spurious line-endings introduced in maintenance-work. * Fixed breakage due to lag time cache, based on a hack in the WMF working copy. * Tested locally. --- includes/db/LoadBalancer.php | 7 +++++++ maintenance/lag.php | 15 ++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 04bcc2a1f1..dcc531661b 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -918,4 +918,11 @@ class LoadBalancer { $this->mLagTimes = $this->getLoadMonitor()->getLagTimes( array_keys( $this->mServers ), $wiki ); return $this->mLagTimes; } + + /** + * Clear the cache for getLagTimes + */ + function clearLagTimeCache() { + $this->mLagTimes = null; + } } diff --git a/maintenance/lag.php b/maintenance/lag.php index d5c19855cd..47b4c47b01 100644 --- a/maintenance/lag.php +++ b/maintenance/lag.php @@ -18,21 +18,22 @@ class DatabaseLag extends Maintenance { public function execute() { if ( $this->hasOption( 'r' ) ) { $lb = wfGetLB(); - $this->output( 'time ' ); - for( $i = 0; $i < $lb->getServerCount(); $i++ ) { + echo 'time '; + for( $i = 1; $i < $lb->getServerCount(); $i++ ) { $hostname = $lb->getServerName( $i ); - $this->output( sprintf( "%-12s ", $hostname ) ); + printf( "%-12s ", $hostname ); } - $this->output( "\n" ); + echo "\n"; while( 1 ) { + $lb->clearLagTimeCache(); $lags = $lb->getLagTimes(); unset( $lags[0] ); - $this->output( gmdate( 'H:i:s' ) . ' ' ); + echo gmdate( 'H:i:s' ) . ' '; foreach( $lags as $i => $lag ) { - $this->output( sprintf( "%-12s " , $lag === false ? 'false' : $lag ) ); + printf( "%-12s " , $lag === false ? 'false' : $lag ); } - $this->output( "\n" ); + echo "\n"; sleep( 5 ); } } else { -- 2.20.1