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

Change subject: Use slave for selects in CategoryMembershipJob
......................................................................


Use slave for selects in CategoryMembershipJob

This patch switches to using a slave but imediatly
waits for the slave to catch up with master
(so as not to miss things).

This may result in more delay between an edit and
category changes being inserted.

It may be possible to instead wait for the timestamp
that is passed in $this->params['revTimestamp']
which could result in slightly less delay.

I can't see any uses of waitForReplication in quite
this way but see no imediate reason this would not work.

Bug: T125147
Change-Id: Ia0aa722c97f41a3959bcd3cb4210b39db0c3bc45
---
M includes/jobqueue/jobs/CategoryMembershipChangeJob.php
1 file changed, 12 insertions(+), 4 deletions(-)

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



diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php 
b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
index a6869c1..d34ea41 100644
--- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
+++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
@@ -63,13 +63,21 @@
                // between COMMIT and actual enqueueing of the 
CategoryMembershipChangeJob job.
                $cutoffUnix -= self::ENQUEUE_FUDGE_SEC;
 
+               $dbr = wfGetDB( DB_SLAVE, array( 'recentchanges' ) );
+               if ( !wfGetLB()->safeWaitForPos( $dbr ) ) {
+                       $this->setLastError( "Timed out while waiting for slave 
to catch up" );
+                       return false;
+               }
+
+               $dbr->commit( __METHOD__, 'flush' );
+
                // Get the newest revision that has a SRC_CATEGORIZE row...
-               $row = $dbw->selectRow(
+               $row = $dbr->selectRow(
                        array( 'revision', 'recentchanges' ),
                        array( 'rev_timestamp', 'rev_id' ),
                        array(
                                'rev_page' => $page->getId(),
-                               'rev_timestamp >= ' . $dbw->addQuotes( 
$dbw->timestamp( $cutoffUnix ) )
+                               'rev_timestamp >= ' . $dbr->addQuotes( 
$dbr->timestamp( $cutoffUnix ) )
                        ),
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_timestamp DESC, rev_id DESC' 
),
@@ -96,8 +104,8 @@
 
                // Find revisions to this page made around and after this 
revision which lack category
                // notifications in recent changes. This lets jobs pick up were 
the last one left off.
-               $encCutoff = $dbw->addQuotes( $dbw->timestamp( $cutoffUnix ) );
-               $res = $dbw->select(
+               $encCutoff = $dbr->addQuotes( $dbr->timestamp( $cutoffUnix ) );
+               $res = $dbr->select(
                        'revision',
                        Revision::selectFields(),
                        array(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia0aa722c97f41a3959bcd3cb4210b39db0c3bc45
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Jcrespo <jcre...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to