From 39ef7941b0dc2ef296846dadbca27d444fc83dd5 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 30 Jan 2016 10:19:36 -0800 Subject: [PATCH] Style and commenting tweaks to CategoryMembershipChangeJob Also renamed safeWaitForPos() => safeWaitForMasterPos() Change-Id: Ic89e2a0b17cd6e6ef09cf703bbbcea1988a5bde9 --- includes/db/loadbalancer/LoadBalancer.php | 2 +- .../jobs/CategoryMembershipChangeJob.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/db/loadbalancer/LoadBalancer.php b/includes/db/loadbalancer/LoadBalancer.php index 719938911c..32999f59fd 100644 --- a/includes/db/loadbalancer/LoadBalancer.php +++ b/includes/db/loadbalancer/LoadBalancer.php @@ -1385,7 +1385,7 @@ class LoadBalancer { * @return bool Success * @since 1.27 */ - public function safeWaitForPos( IDatabase $conn, $pos = false, $timeout = 10 ) { + public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 ) { if ( $this->getServerCount() == 1 || !$conn->getLBInfo( 'slave' ) ) { return true; // server is not a slave DB } diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php index d34ea41bfb..5dc2acbd2f 100644 --- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php +++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php @@ -49,7 +49,6 @@ class CategoryMembershipChangeJob extends Job { } $dbw = wfGetDB( DB_MASTER ); - // Use a named lock so that jobs for this page see each others' changes $lockKey = "CategoryMembershipUpdates:{$page->getId()}"; $scopedLock = $dbw->getScopedLockAndFlush( $lockKey, __METHOD__, 10 ); @@ -58,19 +57,20 @@ class CategoryMembershipChangeJob extends Job { return false; } - $cutoffUnix = wfTimestamp( TS_UNIX, $this->params['revTimestamp'] ); - // Using ENQUEUE_FUDGE_SEC handles jobs inserted out of revision order due to the delay - // between COMMIT and actual enqueueing of the CategoryMembershipChangeJob job. - $cutoffUnix -= self::ENQUEUE_FUDGE_SEC; - $dbr = wfGetDB( DB_SLAVE, array( 'recentchanges' ) ); - if ( !wfGetLB()->safeWaitForPos( $dbr ) ) { + // Wait till the slave is caught up so that jobs for this page see each others' changes + if ( !wfGetLB()->safeWaitForMasterPos( $dbr ) ) { $this->setLastError( "Timed out while waiting for slave to catch up" ); return false; } - + // Clear any stale REPEATABLE-READ snapshot $dbr->commit( __METHOD__, 'flush' ); + $cutoffUnix = wfTimestamp( TS_UNIX, $this->params['revTimestamp'] ); + // Using ENQUEUE_FUDGE_SEC handles jobs inserted out of revision order due to the delay + // between COMMIT and actual enqueueing of the CategoryMembershipChangeJob job. + $cutoffUnix -= self::ENQUEUE_FUDGE_SEC; + // Get the newest revision that has a SRC_CATEGORIZE row... $row = $dbr->selectRow( array( 'revision', 'recentchanges' ), -- 2.20.1