jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/355523 )

Change subject: Properly handle batches of pages to update
......................................................................


Properly handle batches of pages to update

Using LIMIT on UPDATE/DELETE queries is unsafe when using statement-based
replication as you can't ensure the same sets of rows are updated.

Instead, select a batch of problematic page_ids, update by them, then
continue until we don't find any more to fix

Bug: T166261
Change-Id: I8a5d2989285c72450d6a48ccc12d88fdeeb3fb6f
---
M maintenance/fixProofreadIndexPagesContentModel.php
1 file changed, 12 insertions(+), 3 deletions(-)

Approvals:
  jenkins-bot: Verified
  Tpt: Looks good to me, approved



diff --git a/maintenance/fixProofreadIndexPagesContentModel.php 
b/maintenance/fixProofreadIndexPagesContentModel.php
index afd3b6d..a73dd2b 100644
--- a/maintenance/fixProofreadIndexPagesContentModel.php
+++ b/maintenance/fixProofreadIndexPagesContentModel.php
@@ -50,9 +50,9 @@
                $total = 0;
                $namespaceId = ProofreadPage::getIndexNamespaceId();
                do {
-                       $dbw->update(
+                       $pageIds = $dbw->selectFieldValues(
                                'page',
-                               [ 'page_content_model' => 
CONTENT_MODEL_PROOFREAD_INDEX ],
+                               'page_id',
                                [
                                        'page_namespace' => $namespaceId,
                                        'page_content_model' => 
CONTENT_MODEL_WIKITEXT
@@ -60,10 +60,19 @@
                                __METHOD__,
                                [ 'LIMIT' => $this->mBatchSize ]
                        );
+                       if ( !$pageIds ) {
+                               break;
+                       }
+                       $dbw->update(
+                               'page',
+                               [ 'page_content_model' => 
CONTENT_MODEL_PROOFREAD_INDEX ],
+                               [ 'page_id' => $pageIds ],
+                               __METHOD__
+                       );
                        wfWaitForSlaves();
                        $total += $dbw->affectedRows();
                        $this->output( "$total\n" );
-               } while ( $dbw->affectedRows() > 0 );
+               } while ( true );
 
                $this->output( "Update of the content model for Index: pages is 
done.\n" );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8a5d2989285c72450d6a48ccc12d88fdeeb3fb6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to