From: Aaron Schulz Date: Tue, 21 Nov 2017 02:09:52 +0000 (-0800) Subject: Reduce lag waiting time in CategoryMembershipUpdateJob critical section X-Git-Tag: 1.31.0-rc.0~1442^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=b212286144a2454b0a9c68f874d646bbf271ab8b;p=lhc%2Fweb%2Fwiklou.git Reduce lag waiting time in CategoryMembershipUpdateJob critical section Bug: T180793 Change-Id: Icfe8dd16f4194c5d4f88d7547f732acae8b1cfe2 --- diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php index 55c1367c23..cc81a96422 100644 --- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php +++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php @@ -59,6 +59,13 @@ class CategoryMembershipChangeJob extends Job { return false; // deleted? } + // Cut down on the time spent in safeWaitForMasterPos() in the critical section + $dbr = $lb->getConnection( DB_REPLICA, [ 'recentchanges' ] ); + if ( !$lb->safeWaitForMasterPos( $dbr ) ) { + $this->setLastError( "Timed out while pre-waiting for replica DB to catch up" ); + return false; + } + // Use a named lock so that jobs for this page see each others' changes $lockKey = "CategoryMembershipUpdates:{$page->getId()}"; $scopedLock = $dbw->getScopedLockAndFlush( $lockKey, __METHOD__, 3 ); @@ -67,8 +74,7 @@ class CategoryMembershipChangeJob extends Job { return false; } - $dbr = $lb->getConnection( DB_REPLICA, [ 'recentchanges' ] ); - // Wait till the replica DB is caught up so that jobs for this page see each others' changes + // Wait till replica DB is caught up so that jobs for this page see each others' changes if ( !$lb->safeWaitForMasterPos( $dbr ) ) { $this->setLastError( "Timed out while waiting for replica DB to catch up" ); return false;