r63898 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63897‎ | r63898 | r63899 >
Date:05:32, 18 March 2010
Author:tstarling
Status:ok
Tags:
Comment:
* Quieter, more frequent slave waits
* Option to skip the counts for the progress meter, allows faster startup
* Merged from WMF working copy, tested there.
Modified paths:
  • /trunk/phase3/maintenance/storage/recompressTracked.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/storage/recompressTracked.php
@@ -31,11 +31,13 @@
3232 var $copyOnly = false;
3333 var $isChild = false;
3434 var $slaveId = false;
 35+ var $noCount = false;
3536 var $debugLog, $infoLog, $criticalLog;
3637 var $store;
3738
3839 static $optionsWithArgs = array( 'procs', 'slave-id', 'debug-log', 'info-log', 'critical-log' );
3940 static $cmdLineOptionMap = array(
 41+ 'no-count' => 'noCount',
4042 'procs' => 'numProcs',
4143 'copy-only' => 'copyOnly',
4244 'child' => 'isChild',
@@ -259,12 +261,16 @@
260262 $dbr = wfGetDB( DB_SLAVE );
261263 $i = 0;
262264 $startId = 0;
263 - $numPages = $dbr->selectField( 'blob_tracking',
264 - 'COUNT(DISTINCT bt_page)',
265 - # A condition is required so that this query uses the index
266 - array( 'bt_moved' => 0 ),
267 - __METHOD__
268 - );
 265+ if ( $this->noCount ) {
 266+ $numPages = '[unknown]';
 267+ } else {
 268+ $numPages = $dbr->selectField( 'blob_tracking',
 269+ 'COUNT(DISTINCT bt_page)',
 270+ # A condition is required so that this query uses the index
 271+ array( 'bt_moved' => 0 ),
 272+ __METHOD__
 273+ );
 274+ }
269275 if ( $this->copyOnly ) {
270276 $this->info( "Copying pages..." );
271277 } else {
@@ -310,7 +316,7 @@
311317 if ( $current == $end || $this->numBatches >= $this->reportingInterval ) {
312318 $this->numBatches = 0;
313319 $this->info( "$label: $current / $end" );
314 - wfWaitForSlaves( 5 );
 320+ $this->waitForSlaves();
315321 }
316322 }
317323
@@ -321,12 +327,16 @@
322328 $dbr = wfGetDB( DB_SLAVE );
323329 $startId = 0;
324330 $i = 0;
325 - $numOrphans = $dbr->selectField( 'blob_tracking',
326 - 'COUNT(DISTINCT bt_text_id)',
327 - array( 'bt_moved' => 0, 'bt_page' => 0 ),
328 - __METHOD__ );
329 - if ( !$numOrphans ) {
330 - return;
 331+ if ( $this->noCount ) {
 332+ $numOrphans = '[unknown]';
 333+ } else {
 334+ $numOrphans = $dbr->selectField( 'blob_tracking',
 335+ 'COUNT(DISTINCT bt_text_id)',
 336+ array( 'bt_moved' => 0, 'bt_page' => 0 ),
 337+ __METHOD__ );
 338+ if ( !$numOrphans ) {
 339+ return;
 340+ }
331341 }
332342 if ( $this->copyOnly ) {
333343 $this->info( "Copying orphans..." );
@@ -404,7 +414,7 @@
405415 case 'quit':
406416 return;
407417 }
408 - wfWaitForSlaves( 5 );
 418+ $this->waitForSlaves();
409419 }
410420 }
411421
@@ -469,6 +479,7 @@
470480 $this->debug( "$titleText: committing blob with " . $trx->getSize() . " items" );
471481 $trx->commit();
472482 $trx = new CgzCopyTransaction( $this, $this->pageBlobClass );
 483+ $this->waitForSlaves();
473484 }
474485 }
475486 $startId = $row->bt_text_id;
@@ -545,6 +556,9 @@
546557 $this->debug( 'Incomplete: ' . $res->numRows() . ' rows' );
547558 foreach ( $res as $row ) {
548559 $this->moveTextRow( $row->bt_text_id, $row->bt_new_url );
 560+ if ( $row->bt_text_id % 10 == 0 ) {
 561+ $this->waitForSlaves();
 562+ }
549563 }
550564 $startId = $row->bt_text_id;
551565 }
@@ -604,11 +618,26 @@
605619 $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
606620 $trx->commit();
607621 $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
 622+ $this->waitForSlaves();
608623 }
609624 }
610625 $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
611626 $trx->commit();
612627 }
 628+
 629+ /**
 630+ * Wait for slaves (quietly)
 631+ */
 632+ function waitForSlaves() {
 633+ $lb = wfGetLB();
 634+ while ( true ) {
 635+ list( $host, $maxLag ) = $lb->getMaxLag();
 636+ if ( $maxLag < 2 ) {
 637+ break;
 638+ }
 639+ sleep( 5 );
 640+ }
 641+ }
613642 }
614643
615644 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r64049* MFT r63764, r63897, r63898, r63899, r63900, r63901, r63902. Most changes ar...tstarling00:06, 23 March 2010
r64051MFT r63764, r63897, r63898, r63899, r63900, r63901, r63902: assorted working ...tstarling01:21, 23 March 2010

Status & tagging log