From bd8fffe24d61cadd531463bdca48d9f08e9bc4f8 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 1 Dec 2009 01:55:04 +0000 Subject: [PATCH] Reverted r58646 as per my comments on bug 20554. --- RELEASE-NOTES | 1 - includes/GlobalFunctions.php | 15 --------------- includes/Wiki.php | 18 ------------------ includes/api/ApiBase.php | 8 -------- includes/api/ApiHelp.php | 4 ---- includes/api/ApiMain.php | 18 ------------------ includes/api/ApiQuery.php | 4 ---- includes/api/ApiQuerySiteinfo.php | 1 - includes/db/LoadBalancer.php | 21 --------------------- index.php | 5 ----- 10 files changed, 95 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 75113ca626..6f1c468d13 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -718,7 +718,6 @@ Hopefully we will remove this configuration var soon) * (bug 19004) Added support for tags * (bug 21083) list=allusers no longer returns current timestamp for users without registration date -* (bug 20554) Expose average slave lag (avglag) as well as maxlag * (bug 20967) action=edit allows creation of invalid titles * (bug 19523) Add inprop=watched to prop=info * (bug 21589) API: Separate summary and initial page text for uploads diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 53e0b87044..57c33c472b 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3081,21 +3081,6 @@ function wfMaxlagError( $host, $lag, $maxLag ) { } } -/** - * Displays a avglag error - * - * @param $lag Integer: avglag (actual) - * @param $avgLag Integer: avglag (requested) - */ -function wfAvglagError( $lag, $avgLag ) { - header( 'HTTP/1.1 503 Service Unavailable' ); - header( 'Retry-After: ' . max( intval( $avgLag ), 5 ) ); - header( 'X-Database-Lag: ' . intval( $lag ) ); - header( 'Content-Type: text/plain' ); - - echo "Lagged: $lag seconds average\n"; -} - /** * Throws a warning that $function is deprecated * @param $function String diff --git a/includes/Wiki.php b/includes/Wiki.php index e3924a1cdd..ffa9dd44cd 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -95,24 +95,6 @@ class MediaWiki { return true; } } - - /** - * Check if the average lag of database slaves is higher that $avgLag, and - * if it's the case, output an error message - * - * @param $avgLag int: maximum lag allowed for the request, as supplied by - * the client - * @return bool true if the request can continue - */ - function checkAvgLag( $avgLag ) { - list( $host, $lag ) = wfGetLB()->getAvgLag(); - if( $lag > $avgLag ) { - wfAvglagError( $lag, $avgLag ); - return false; - } else { - return true; - } - } /** * Checks some initial queries diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 0d1db32b7c..dd496b85b5 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -935,14 +935,6 @@ abstract class ApiBase { public function shouldCheckMaxlag() { return true; } - - /** - * Indicates if this module needs avglag to be checked - * @return bool - */ - public function shouldCheckAvglag() { - return true; - } /** * Indicates whether this module requires read rights diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index 02000626e7..982bf4d5ea 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -49,10 +49,6 @@ class ApiHelp extends ApiBase { public function shouldCheckMaxlag() { return false; } - - public function shouldCheckAvglag() { - return false; - } public function isReadMode() { return false; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index e930e7fb1f..6867193d25 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -394,20 +394,6 @@ class ApiMain extends ApiBase { return; } } - - if( $module->shouldCheckAvglag() && isset( $params['avglag'] ) ) { - // Check for avglag - global $wgShowHostnames; - $avgLag = $params['avglag']; - $lag = wfGetLB()->getAvgLag(); - if ( $lag > $avgLag ) { - header( 'Retry-After: ' . max( intval( $avgLag ), 5 ) ); - header( 'X-Database-Lag: ' . intval( $lag ) ); - - $this->dieUsage( "Lag: $lag seconds average", 'avglag' ); - return; - } - } global $wgUser; if ($module->isReadMode() && !$wgUser->isAllowed('read')) @@ -491,9 +477,6 @@ class ApiMain extends ApiBase { 'maxlag' => array ( ApiBase :: PARAM_TYPE => 'integer' ), - 'avglag' => array ( - ApiBase :: PARAM_TYPE => 'integer' - ), 'smaxage' => array ( ApiBase :: PARAM_TYPE => 'integer', ApiBase :: PARAM_DFLT => 0 @@ -515,7 +498,6 @@ class ApiMain extends ApiBase { 'action' => 'What action you would like to perform', 'version' => 'When showing help, include version for each module', 'maxlag' => 'Maximum lag', - 'avglag' => 'Average lag', 'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached', 'maxage' => 'Set the max-age header to this many seconds. Errors are never cached', 'requestid' => 'Request ID to distinguish requests. This will just be output back to you', diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index f2e90b18bc..e15edb68a1 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -548,10 +548,6 @@ class ApiQuery extends ApiBase { public function shouldCheckMaxlag() { return true; } - - public function shouldCheckAvglag() { - return true; - } public function getParamDescription() { return array ( diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 287887bced..8439e471a2 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -295,7 +295,6 @@ class ApiQuerySiteinfo extends ApiQueryBase { ); } - $data['avglag'] = wfGetLB()->getAvgLag(); $result = $this->getResult(); $result->setIndexedTagName( $data, 'db' ); return $this->getResult()->addValue( 'query', $property, $data ); diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 5e91f1ee40..0b8ef05a08 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -898,27 +898,6 @@ class LoadBalancer { } return array( $host, $maxLag ); } - - /** - * Gets the average lag of slaves. - * May attempt to open connections to slaves on the default DB. - */ - function getAvgLag() { - $lag = 0; - $count = 0; - foreach ( $this->mServers as $i => $conn ) { - $conn = $this->getAnyOpenConnection( $i ); - if ( !$conn ) { - $conn = $this->openConnection( $i ); - } - if ( !$conn ) { - continue; - } - $lag += $conn->getLag(); - $count++; - } - return ($count > 1) ? $lag / $count : $lag; - } /** * Get lag time for each server diff --git a/index.php b/index.php index bbc77e58ed..1cbba1e89f 100644 --- a/index.php +++ b/index.php @@ -53,11 +53,6 @@ if( !is_null( $maxLag ) && !$mediaWiki->checkMaxLag( $maxLag ) ) { exit; } -$avgLag = $wgRequest->getVal( 'avglag' ); -if( !is_null( $avgLag ) && !$mediaWiki->checkAvgLag( $avgLag ) ) { - exit; -} - # Query string fields $action = $wgRequest->getVal( 'action', 'view' ); $title = $wgRequest->getVal( 'title' ); -- 2.20.1