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

Change subject: Try not to make slave lag in updateRecentChanges()
......................................................................


Try not to make slave lag in updateRecentChanges()

Do the update by selecting what needs to change first rather than
doing scanning, which can be expensive for hot pages. Also, only
update rows that need it.

Change-Id: Ie76d7a9b4200b4544f29a9e93949dabde5cb03d7
---
M business/RevisionReviewForm.php
1 file changed, 26 insertions(+), 11 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/business/RevisionReviewForm.php b/business/RevisionReviewForm.php
index 4006065..416cd02 100644
--- a/business/RevisionReviewForm.php
+++ b/business/RevisionReviewForm.php
@@ -557,27 +557,42 @@
                        # If $wgUseNPPatrol is off, then not even those are 
used.
                        $conds['rc_type'] = RC_NEW; // reduce rows to UPDATE
                }
+
+               $newPatrolState = null; // set rc_patrolled to this value
                # If we accepted this rev, then mark prior revs as patrolled...
                if ( $patrol === 'patrol' ) {
                        if ( $sTimestamp ) { // sanity check; should always be 
set
                                $conds[] = 'rc_timestamp <= ' . 
$dbw->addQuotes( $dbw->timestamp( $sTimestamp ) );
-                               $dbw->update( 'recentchanges',
-                                       array( 'rc_patrolled' => 1 ),
-                                       $conds,
-                                       __METHOD__,
-                                       array( 'LIMIT' => $limit ) // 
performance
-                               );
+                               $newPatrolState = 1;
                        }
                # If we un-accepted this rev, then mark now-pending revs as 
unpatrolled...
                } elseif ( $patrol === 'unpatrol' ) {
                        if ( $sTimestamp ) {
                                $conds[] = 'rc_timestamp > ' . $dbw->addQuotes( 
$dbw->timestamp( $sTimestamp ) );
                        }
-                       $dbw->update( 'recentchanges',
-                               array( 'rc_patrolled' => 0 ),
-                               $conds,
-                               __METHOD__,
-                               array( 'LIMIT' => $limit ) // performance
+                       $newPatrolState = 0;
+               }
+
+               if ( $newPatrolState === null ) {
+                       return; // leave alone
+               }
+
+               // Only update rows that need it
+               $conds['rc_patrolled'] = $newPatrolState ? 0 : 1;
+               // SELECT and update by PK to avoid lag
+               $rcIds = $dbw->selectFieldValues(
+                       'recentchanges',
+                       'rc_id',
+                       $conds,
+                       __METHOD__,
+                       [ 'LIMIT' => $limit ]
+               );
+               if ( $rcIds ) {
+                       $dbw->update(
+                               'recentchanges',
+                               [ 'rc_patrolled' => $newPatrolState ],
+                               [ 'rc_id' => $rcIds ],
+                               __METHOD__
                        );
                }
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie76d7a9b4200b4544f29a9e93949dabde5cb03d7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to