jenkins-bot has submitted this change and it was merged.

Change subject: Batch the updates done for page delete/restore handling
......................................................................


Batch the updates done for page delete/restore handling

If a user had few deleted edits but many live ones, then the
archive ranges will be huge. If any edits by the user are
restored mid-rename, then the logic will update all live
edits for the user in the huge range, which will make
high slave lag.

Bug: T116425
Change-Id: I4995190a1f91c85d10e0496a4ccd11e7ee5c627a
---
M RenameUserJob.php
1 file changed, 10 insertions(+), 4 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RenameUserJob.php b/RenameUserJob.php
index 75c4a39..8b9d585 100644
--- a/RenameUserJob.php
+++ b/RenameUserJob.php
@@ -119,11 +119,14 @@
                                ),
                                __METHOD__
                        );
-                       if ( $ids ) {
+                       foreach ( array_chunk( $ids, $wgUpdateRowsPerQuery ) as 
$batch ) {
+                               $dbw->commit( __METHOD__, 'flush' );
+                               wfWaitForSlaves();
+
                                $dbw->update(
                                        'archive',
                                        array( 'ar_user_text' => $newname ),
-                                       array( 'ar_user_text' => $oldname, 
'ar_id' => $ids ),
+                                       array( 'ar_user_text' => $oldname, 
'ar_id' => $batch ),
                                        __METHOD__
                                );
                        }
@@ -145,11 +148,14 @@
                                ),
                                __METHOD__
                        );
-                       if ( $ids ) {
+                       foreach ( array_chunk( $ids, $wgUpdateRowsPerQuery ) as 
$batch ) {
+                               $dbw->commit( __METHOD__, 'flush' );
+                               wfWaitForSlaves();
+
                                $dbw->update(
                                        'revision',
                                        array( 'rev_user_text' => $newname ),
-                                       array( 'rev_user_text' => $oldname, 
'rev_id' => $ids ),
+                                       array( 'rev_user_text' => $oldname, 
'rev_id' => $batch ),
                                        __METHOD__
                                );
                        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4995190a1f91c85d10e0496a4ccd11e7ee5c627a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Renameuser
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to