From: Tim Starling Date: Sat, 20 Sep 2008 15:00:53 +0000 (+0000) Subject: Don't run hour-long, unlimited row-count DB queries with set_time_limit(0) in respons... X-Git-Tag: 1.31.0-rc.0~45193 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/fiche.php?a=commitdiff_plain;h=9b8782aaa8d8a8d20e95217c16d50a13178de724;p=lhc%2Fweb%2Fwiklou.git Don't run hour-long, unlimited row-count DB queries with set_time_limit(0) in response to unauthenticated web requests on the Run them on the slave instead. Maybe we can crash the whole cluster instead of just a master or two. Don't use DB_LAST, ever again. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1024ecfb3c..6d40652e81 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -212,6 +212,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14638) Special:Blockip now provides a link to the block log if the user has been blocked more than 10 times. Patch by Matt Johnston. * (bug 12678) Skins don't show Upload link if the user isn't allowed to upload. +* Fixed incorrect usage of DB_LAST in Special:Export. Deprecated DB_LAST. === API changes in 1.14 === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 44d35120da..5733c957a5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2644,7 +2644,7 @@ function wfSplitWikiID( $wiki ) { * will always return the same object, unless the underlying connection or load * balancer is manually destroyed. */ -function &wfGetDB( $db = DB_LAST, $groups = array(), $wiki = false ) { +function &wfGetDB( $db, $groups = array(), $wiki = false ) { return wfGetLB( $wiki )->getConnection( $db, $groups, $wiki ); } diff --git a/includes/db/Database.php b/includes/db/Database.php index ed5c05c1bc..476260dc32 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -372,7 +372,7 @@ class Database { if ( !$error ) { $error = $phpError; } - wfLogDBError( "Connection error: $error\n" ); + wfLogDBError( "Error connecting to {$this->mServer}: $error\n" ); } wfProfileOut("dbconnect-$server"); diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index dd0c66b562..733ee5ee38 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -15,7 +15,7 @@ class LoadBalancer { /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads; /* private */ var $mFailFunction, $mErrorConnection; - /* private */ var $mReadIndex, $mLastIndex, $mAllowLagged; + /* private */ var $mReadIndex, $mAllowLagged; /* private */ var $mWaitForPos, $mWaitTimeout; /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; /* private */ var $mParentInfo, $mLagTimes; @@ -52,7 +52,6 @@ class LoadBalancer { 'local' => array(), 'foreignUsed' => array(), 'foreignFree' => array() ); - $this->mLastIndex = -1; $this->mLoads = array(); $this->mWaitForPos = false; $this->mLaggedSlaveMode = false; @@ -441,13 +440,7 @@ class LoadBalancer { if ( $i == DB_SLAVE ) { $i = $this->getReaderIndex( false, $wiki, $attempts ); } elseif ( $i == DB_LAST ) { - # Just use $this->mLastIndex, which should already be set - $i = $this->mLastIndex; - if ( $i === -1 ) { - # Oh dear, not set, best to use the writer for safety - wfDebug( "Warning: DB_LAST used when there was no previous index\n" ); - $i = $this->getWriterIndex(); - } + throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' ); } # Couldn't find a working server in getReaderIndex()? if ( $i === false ) { @@ -545,7 +538,6 @@ class LoadBalancer { $conn = false; } } - $this->mLastIndex = $i; wfProfileOut( __METHOD__ ); return $conn; } diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index 5021e96fc3..32a43ec0a5 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -230,7 +230,7 @@ function wfSpecialExport( $page = '' ) { } else { // Use an unbuffered query; histories may be very long! $lb = wfGetLBFactory()->newMainLB(); - $db = $lb->getConnection( DB_LAST ); + $db = $lb->getConnection( DB_SLAVE ); $buffer = WikiExporter::STREAM; // This might take a while... :D