Index: trunk/phase3/maintenance/storage/recompressTracked.php |
— | — | @@ -31,11 +31,13 @@ |
32 | 32 | var $copyOnly = false; |
33 | 33 | var $isChild = false; |
34 | 34 | var $slaveId = false; |
| 35 | + var $noCount = false; |
35 | 36 | var $debugLog, $infoLog, $criticalLog; |
36 | 37 | var $store; |
37 | 38 | |
38 | 39 | static $optionsWithArgs = array( 'procs', 'slave-id', 'debug-log', 'info-log', 'critical-log' ); |
39 | 40 | static $cmdLineOptionMap = array( |
| 41 | + 'no-count' => 'noCount', |
40 | 42 | 'procs' => 'numProcs', |
41 | 43 | 'copy-only' => 'copyOnly', |
42 | 44 | 'child' => 'isChild', |
— | — | @@ -259,12 +261,16 @@ |
260 | 262 | $dbr = wfGetDB( DB_SLAVE ); |
261 | 263 | $i = 0; |
262 | 264 | $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 | + } |
269 | 275 | if ( $this->copyOnly ) { |
270 | 276 | $this->info( "Copying pages..." ); |
271 | 277 | } else { |
— | — | @@ -310,7 +316,7 @@ |
311 | 317 | if ( $current == $end || $this->numBatches >= $this->reportingInterval ) { |
312 | 318 | $this->numBatches = 0; |
313 | 319 | $this->info( "$label: $current / $end" ); |
314 | | - wfWaitForSlaves( 5 ); |
| 320 | + $this->waitForSlaves(); |
315 | 321 | } |
316 | 322 | } |
317 | 323 | |
— | — | @@ -321,12 +327,16 @@ |
322 | 328 | $dbr = wfGetDB( DB_SLAVE ); |
323 | 329 | $startId = 0; |
324 | 330 | $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 | + } |
331 | 341 | } |
332 | 342 | if ( $this->copyOnly ) { |
333 | 343 | $this->info( "Copying orphans..." ); |
— | — | @@ -404,7 +414,7 @@ |
405 | 415 | case 'quit': |
406 | 416 | return; |
407 | 417 | } |
408 | | - wfWaitForSlaves( 5 ); |
| 418 | + $this->waitForSlaves(); |
409 | 419 | } |
410 | 420 | } |
411 | 421 | |
— | — | @@ -469,6 +479,7 @@ |
470 | 480 | $this->debug( "$titleText: committing blob with " . $trx->getSize() . " items" ); |
471 | 481 | $trx->commit(); |
472 | 482 | $trx = new CgzCopyTransaction( $this, $this->pageBlobClass ); |
| 483 | + $this->waitForSlaves(); |
473 | 484 | } |
474 | 485 | } |
475 | 486 | $startId = $row->bt_text_id; |
— | — | @@ -545,6 +556,9 @@ |
546 | 557 | $this->debug( 'Incomplete: ' . $res->numRows() . ' rows' ); |
547 | 558 | foreach ( $res as $row ) { |
548 | 559 | $this->moveTextRow( $row->bt_text_id, $row->bt_new_url ); |
| 560 | + if ( $row->bt_text_id % 10 == 0 ) { |
| 561 | + $this->waitForSlaves(); |
| 562 | + } |
549 | 563 | } |
550 | 564 | $startId = $row->bt_text_id; |
551 | 565 | } |
— | — | @@ -604,11 +618,26 @@ |
605 | 619 | $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" ); |
606 | 620 | $trx->commit(); |
607 | 621 | $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass ); |
| 622 | + $this->waitForSlaves(); |
608 | 623 | } |
609 | 624 | } |
610 | 625 | $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" ); |
611 | 626 | $trx->commit(); |
612 | 627 | } |
| 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 | + } |
613 | 642 | } |
614 | 643 | |
615 | 644 | /** |