From db7e32441d2ae823d8c73506f4f13fad55ba7164 Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Mon, 18 Sep 2017 16:57:26 -0400 Subject: [PATCH] Attempt to fix populateIpChanges maintenance script With the previous edition, some IP revisions failed to copy, e.g. rev_id 1507693 on enwikivoyage. This change first fixes to go by mBatchSize, and removes other redundant clauses in the query. Bug: T175962 Change-Id: Ia5f3e275d8bef120090b4c60e6aec4c204d55d53 --- maintenance/populateIpChanges.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/maintenance/populateIpChanges.php b/maintenance/populateIpChanges.php index c173270d21..17f49ee358 100644 --- a/maintenance/populateIpChanges.php +++ b/maintenance/populateIpChanges.php @@ -77,25 +77,26 @@ TEXT $this->output( "Copying IP revisions to ip_changes, from rev_id $start to rev_id $end\n" ); while ( $blockStart <= $end ) { - $blockEnd = min( $blockStart + 200, $end ); + $blockEnd = min( $blockStart + $this->mBatchSize, $end ); $rows = $dbr->select( 'revision', [ 'rev_id', 'rev_timestamp', 'rev_user_text' ], [ "rev_id BETWEEN $blockStart AND $blockEnd", 'rev_user' => 0 ], - __METHOD__, - [ 'ORDER BY' => 'rev_id ASC', 'LIMIT' => $this->mBatchSize ] + __METHOD__ ); - if ( !$rows || $rows->numRows() === 0 ) { + $numRows = $rows->numRows(); + + if ( !$rows || $numRows === 0 ) { break; } - $this->output( "...checking $this->mBatchSize revisions for IP edits that need copying, " . + $this->output( "...checking $numRows revisions for IP edits that need copying, " . "between rev_ids $blockStart and $blockEnd\n" ); $insertRows = []; foreach ( $rows as $row ) { - // Double-check to make sure this is an IP, e.g. not maintenance user or imported revision. + // Make sure this is really an IP, e.g. not maintenance user or imported revision. if ( IP::isValid( $row->rev_user_text ) ) { $insertRows[] = [ 'ipc_rev_id' => $row->rev_id, @@ -105,12 +106,8 @@ TEXT $revCount++; } - - $blockStart = (int)$row->rev_id; } - $blockStart++; - $dbw->insert( 'ip_changes', $insertRows, @@ -120,6 +117,8 @@ TEXT $lbFactory->waitForReplication(); usleep( $throttle * 1000 ); + + $blockStart = $blockEnd + 1; } $this->output( "$revCount IP revisions copied.\n" ); -- 2.20.1