From: Max Semenik Date: Wed, 8 Nov 2017 03:35:11 +0000 (-0800) Subject: Finish migration to Maintenance::getBatchSize() X-Git-Tag: 1.31.0-rc.0~1575 X-Git-Url: https://git.cyclocoop.org/%20%27.%28%24debut%20%20%20%24par_page%29.%27?a=commitdiff_plain;h=55a9b2f8b6463f94a35e5e914167de2357961c19;p=lhc%2Fweb%2Fwiklou.git Finish migration to Maintenance::getBatchSize() Change-Id: I02d89f71d820e4d00a39e86a30397b614bbdb432 --- diff --git a/maintenance/populateRecentChangesSource.php b/maintenance/populateRecentChangesSource.php index 5d5da89a8c..eb9797f0b0 100644 --- a/maintenance/populateRecentChangesSource.php +++ b/maintenance/populateRecentChangesSource.php @@ -41,6 +41,7 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { protected function doDBUpdates() { $dbw = $this->getDB( DB_MASTER ); + $batchSize = $this->getBatchSize(); if ( !$dbw->fieldExists( 'recentchanges', 'rc_source' ) ) { $this->error( 'rc_source field in recentchanges table does not exist.' ); } @@ -52,9 +53,9 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { return true; } $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', false, __METHOD__ ); - $end += $this->mBatchSize - 1; + $end += $batchSize - 1; $blockStart = $start; - $blockEnd = $start + $this->mBatchSize - 1; + $blockEnd = $start + $batchSize - 1; $updatedValues = $this->buildUpdateCondition( $dbw ); @@ -74,8 +75,8 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { $this->output( "." ); wfWaitForSlaves(); - $blockStart += $this->mBatchSize; - $blockEnd += $this->mBatchSize; + $blockStart += $batchSize; + $blockEnd += $batchSize; } $this->output( "\nDone.\n" ); diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 0cb14c42c8..5de5819735 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -75,6 +75,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { protected function doLenUpdates( $table, $idCol, $prefix, $queryInfo ) { $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); + $batchSize = $this->getBatchSize(); $start = $dbw->selectField( $table, "MIN($idCol)", false, __METHOD__ ); $end = $dbw->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { @@ -85,7 +86,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { # Do remaining chunks $blockStart = intval( $start ); - $blockEnd = intval( $start ) + $this->mBatchSize - 1; + $blockEnd = intval( $start ) + $batchSize - 1; $count = 0; while ( $blockStart <= $end ) { @@ -114,8 +115,8 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $this->commitTransaction( $dbw, __METHOD__ ); } - $blockStart += $this->mBatchSize; - $blockEnd += $this->mBatchSize; + $blockStart += $batchSize; + $blockEnd += $batchSize; wfWaitForSlaves(); } diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php index f96c2eca36..89eff02159 100644 --- a/maintenance/populateRevisionSha1.php +++ b/maintenance/populateRevisionSha1.php @@ -77,6 +77,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { */ protected function doSha1Updates( $table, $idCol, $queryInfo, $prefix ) { $db = $this->getDB( DB_MASTER ); + $batchSize = $this->getBatchSize(); $start = $db->selectField( $table, "MIN($idCol)", false, __METHOD__ ); $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { @@ -87,9 +88,9 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $count = 0; # Do remaining chunk - $end += $this->mBatchSize - 1; + $end += $batchSize - 1; $blockStart = $start; - $blockEnd = $start + $this->mBatchSize - 1; + $blockEnd = $start + $batchSize - 1; while ( $blockEnd <= $end ) { $this->output( "...doing $idCol from $blockStart to $blockEnd\n" ); $cond = "$idCol BETWEEN $blockStart AND $blockEnd @@ -106,8 +107,8 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { } $this->commitTransaction( $db, __METHOD__ ); - $blockStart += $this->mBatchSize; - $blockEnd += $this->mBatchSize; + $blockStart += $batchSize; + $blockEnd += $batchSize; wfWaitForSlaves(); } diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index fe3944c876..19d8d06154 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -78,6 +78,7 @@ class RebuildFileCache extends Maintenance { $this->output( "Building content page file cache from page {$start}!\n" ); $dbr = $this->getDB( DB_REPLICA ); + $batchSize = $this->getBatchSize(); $overwrite = $this->hasOption( 'overwrite' ); $start = ( $start > 0 ) ? $start @@ -92,9 +93,9 @@ class RebuildFileCache extends Maintenance { $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; // hack, no real client # Do remaining chunk - $end += $this->mBatchSize - 1; + $end += $batchSize - 1; $blockStart = $start; - $blockEnd = $start + $this->mBatchSize - 1; + $blockEnd = $start + $batchSize - 1; $dbw = $this->getDB( DB_MASTER ); // Go through each page and save the output @@ -171,8 +172,8 @@ class RebuildFileCache extends Maintenance { } $this->commitTransaction( $dbw, __METHOD__ ); // commit any changes (just for sanity) - $blockStart += $this->mBatchSize; - $blockEnd += $this->mBatchSize; + $blockStart += $batchSize; + $blockEnd += $batchSize; } $this->output( "Done!\n" ); } diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index 8003ee0a60..6d4a4bfb10 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -109,7 +109,7 @@ class RebuildRecentchanges extends Maintenance { 'rc_timestamp < ' . $dbw->addQuotes( $dbw->timestamp( $this->cutoffTo ) ) ] ); - foreach ( array_chunk( $rcids, $this->mBatchSize ) as $rcidBatch ) { + foreach ( array_chunk( $rcids, $this->getBatchSize() ) as $rcidBatch ) { $dbw->delete( 'recentchanges', [ 'rc_id' => $rcidBatch ], __METHOD__ ); wfGetLBFactory()->waitForReplication(); } @@ -166,7 +166,7 @@ class RebuildRecentchanges extends Maintenance { ] + $rcCommentStore->insert( $dbw, $comment ), __METHOD__ ); - if ( ( ++$inserted % $this->mBatchSize ) == 0 ) { + if ( ( ++$inserted % $this->getBatchSize() ) == 0 ) { wfGetLBFactory()->waitForReplication(); } } diff --git a/maintenance/refreshImageMetadata.php b/maintenance/refreshImageMetadata.php index b7f03d9bb6..f6c0673b10 100644 --- a/maintenance/refreshImageMetadata.php +++ b/maintenance/refreshImageMetadata.php @@ -106,7 +106,8 @@ class RefreshImageMetadata extends Maintenance { $error = 0; $dbw = $this->getDB( DB_MASTER ); - if ( $this->mBatchSize <= 0 ) { + $batchSize = $this->getBatchSize(); + if ( $batchSize <= 0 ) { $this->error( "Batch size is too low...", 12 ); } @@ -120,7 +121,7 @@ class RefreshImageMetadata extends Maintenance { } $options = [ - 'LIMIT' => $this->mBatchSize, + 'LIMIT' => $batchSize, 'ORDER BY' => 'img_name ASC', ]; @@ -194,7 +195,7 @@ class RefreshImageMetadata extends Maintenance { } $conds2 = [ 'img_name > ' . $dbw->addQuotes( $row->img_name ) ]; wfWaitForSlaves(); - } while ( $res->numRows() === $this->mBatchSize ); + } while ( $res->numRows() === $batchSize ); $total = $upgraded + $leftAlone; if ( $force ) { diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index b099aff44f..cea9e0cbab 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -80,9 +80,9 @@ class RefreshLinks extends Maintenance { $redir = $this->hasOption( 'redirects-only' ); $oldRedir = $this->hasOption( 'old-redirects-only' ); $this->doRefreshLinks( $start, $new, $end, $redir, $oldRedir ); - $this->deleteLinksFromNonexistent( null, null, $this->mBatchSize, $dfnChunkSize ); + $this->deleteLinksFromNonexistent( null, null, $this->getBatchSize(), $dfnChunkSize ); } else { - $this->deleteLinksFromNonexistent( $start, $end, $this->mBatchSize, $dfnChunkSize ); + $this->deleteLinksFromNonexistent( $start, $end, $this->getBatchSize(), $dfnChunkSize ); } } @@ -456,7 +456,7 @@ class RefreshLinks extends Maintenance { __METHOD__, [ 'ORDER BY' => [ 'cl_timestamp', 'cl_from' ], - 'LIMIT' => $this->mBatchSize, + 'LIMIT' => $this->getBatchSize(), ] ); @@ -470,7 +470,7 @@ class RefreshLinks extends Maintenance { self::fixLinksFromArticle( $row->page_id ); } - } while ( $res->numRows() == $this->mBatchSize ); + } while ( $res->numRows() == $this->getBatchSize() ); } /** diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index 2f3fc36534..334ed279f6 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -41,6 +41,7 @@ class UpdateRestrictions extends Maintenance { public function execute() { $db = $this->getDB( DB_MASTER ); + $batchSize = $this->getBatchSize(); if ( !$db->tableExists( 'page_restrictions' ) ) { $this->error( "page_restrictions table does not exist", true ); } @@ -52,9 +53,9 @@ class UpdateRestrictions extends Maintenance { $end = $db->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); # Do remaining chunk - $end += $this->mBatchSize - 1; + $end += $batchSize - 1; $blockStart = $start; - $blockEnd = $start + $this->mBatchSize - 1; + $blockEnd = $start + $batchSize - 1; $encodedExpiry = 'infinity'; while ( $blockEnd <= $end ) { $this->output( "...doing page_id from $blockStart to $blockEnd out of $end\n" ); @@ -105,8 +106,8 @@ class UpdateRestrictions extends Maintenance { throw new MWException( "Deadlock loop failed wtf :(" ); } } - $blockStart += $this->mBatchSize - 1; - $blockEnd += $this->mBatchSize - 1; + $blockStart += $batchSize - 1; + $blockEnd += $batchSize - 1; wfWaitForSlaves(); } $this->output( "...removing dead rows from page_restrictions\n" );