r41074 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41073‎ | r41074 | r41075 >
Date:15:00, 20 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Don't run hour-long, unlimited row-count DB queries with set_time_limit(0) in response to unauthenticated web requests on the master. 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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/LoadBalancer.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialExport.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2644,7 +2644,7 @@
26452645 * will always return the same object, unless the underlying connection or load
26462646 * balancer is manually destroyed.
26472647 */
2648 -function &wfGetDB( $db = DB_LAST, $groups = array(), $wiki = false ) {
 2648+function &wfGetDB( $db, $groups = array(), $wiki = false ) {
26492649 return wfGetLB( $wiki )->getConnection( $db, $groups, $wiki );
26502650 }
26512651
Index: trunk/phase3/includes/db/Database.php
@@ -372,7 +372,7 @@
373373 if ( !$error ) {
374374 $error = $phpError;
375375 }
376 - wfLogDBError( "Connection error: $error\n" );
 376+ wfLogDBError( "Error connecting to {$this->mServer}: $error\n" );
377377 }
378378
379379 wfProfileOut("dbconnect-$server");
Index: trunk/phase3/includes/db/LoadBalancer.php
@@ -15,7 +15,7 @@
1616
1717 /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads;
1818 /* private */ var $mFailFunction, $mErrorConnection;
19 - /* private */ var $mReadIndex, $mLastIndex, $mAllowLagged;
 19+ /* private */ var $mReadIndex, $mAllowLagged;
2020 /* private */ var $mWaitForPos, $mWaitTimeout;
2121 /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error';
2222 /* private */ var $mParentInfo, $mLagTimes;
@@ -52,7 +52,6 @@
5353 'local' => array(),
5454 'foreignUsed' => array(),
5555 'foreignFree' => array() );
56 - $this->mLastIndex = -1;
5756 $this->mLoads = array();
5857 $this->mWaitForPos = false;
5958 $this->mLaggedSlaveMode = false;
@@ -441,13 +440,7 @@
442441 if ( $i == DB_SLAVE ) {
443442 $i = $this->getReaderIndex( false, $wiki, $attempts );
444443 } elseif ( $i == DB_LAST ) {
445 - # Just use $this->mLastIndex, which should already be set
446 - $i = $this->mLastIndex;
447 - if ( $i === -1 ) {
448 - # Oh dear, not set, best to use the writer for safety
449 - wfDebug( "Warning: DB_LAST used when there was no previous index\n" );
450 - $i = $this->getWriterIndex();
451 - }
 444+ throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' );
452445 }
453446 # Couldn't find a working server in getReaderIndex()?
454447 if ( $i === false ) {
@@ -545,7 +538,6 @@
546539 $conn = false;
547540 }
548541 }
549 - $this->mLastIndex = $i;
550542 wfProfileOut( __METHOD__ );
551543 return $conn;
552544 }
Index: trunk/phase3/includes/specials/SpecialExport.php
@@ -230,7 +230,7 @@
231231 } else {
232232 // Use an unbuffered query; histories may be very long!
233233 $lb = wfGetLBFactory()->newMainLB();
234 - $db = $lb->getConnection( DB_LAST );
 234+ $db = $lb->getConnection( DB_SLAVE );
235235 $buffer = WikiExporter::STREAM;
236236
237237 // This might take a while... :D
Index: trunk/phase3/RELEASE-NOTES
@@ -212,6 +212,7 @@
213213 * (bug 14638) Special:Blockip now provides a link to the block log if the user
214214 has been blocked more than 10 times. Patch by Matt Johnston.
215215 * (bug 12678) Skins don't show Upload link if the user isn't allowed to upload.
 216+* Fixed incorrect usage of DB_LAST in Special:Export. Deprecated DB_LAST.
216217
217218 === API changes in 1.14 ===
218219