Don't run hour-long, unlimited row-count DB queries with set_time_limit(0) in respons...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 20 Sep 2008 15:00:53 +0000 (15:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 20 Sep 2008 15:00:53 +0000 (15:00 +0000)
Don't use DB_LAST, ever again.

RELEASE-NOTES
includes/GlobalFunctions.php
includes/db/Database.php
includes/db/LoadBalancer.php
includes/specials/SpecialExport.php

index 1024ecf..6d40652 100644 (file)
@@ -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 ===
 
index 44d3512..5733c95 100644 (file)
@@ -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 );
 }
 
index ed5c05c..476260d 100644 (file)
@@ -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");
index dd0c66b..733ee5e 100644 (file)
@@ -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;
        }
index 5021e96..32a43ec 100644 (file)
@@ -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