MusikAnimal has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378798 )

Change subject: Attempt to fix populateIpChanges maintenance script
......................................................................

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
---
M maintenance/populateIpChanges.php
1 file changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/98/378798/1

diff --git a/maintenance/populateIpChanges.php 
b/maintenance/populateIpChanges.php
index c173270..998d4ea 100644
--- a/maintenance/populateIpChanges.php
+++ b/maintenance/populateIpChanges.php
@@ -63,7 +63,6 @@
 
        public function doDBUpdates() {
                $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
-               $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
                $dbw = $this->getDB( DB_MASTER );
                $throttle = intval( $this->getOption( 'throttle', 0 ) );
                $maxRevId = intval( $this->getOption( 'max-rev-id', 0 ) );
@@ -77,25 +76,26 @@
                $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 );
-                       $rows = $dbr->select(
+                       $blockEnd = min( $blockStart + $this->mBatchSize, $end 
);
+                       $rows = $dbw->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,

-- 
To view, visit https://gerrit.wikimedia.org/r/378798
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5f3e275d8bef120090b4c60e6aec4c204d55d53
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MusikAnimal <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to