Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/303417
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 changes 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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs
refs/changes/17/303417/1
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: newchange
Gerrit-Change-Id: Ie76d7a9b4200b4544f29a9e93949dabde5cb03d7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits