jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/392558 )

Change subject: Reduce lag waiting time in CategoryMembershipUpdateJob critical 
section
......................................................................


Reduce lag waiting time in CategoryMembershipUpdateJob critical section

Bug: T180793
Change-Id: Icfe8dd16f4194c5d4f88d7547f732acae8b1cfe2
---
M includes/jobqueue/jobs/CategoryMembershipChangeJob.php
1 file changed, 8 insertions(+), 2 deletions(-)

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



diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php 
b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
index 55c1367..cc81a96 100644
--- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
+++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
@@ -59,6 +59,13 @@
                        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 @@
                        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;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icfe8dd16f4194c5d4f88d7547f732acae8b1cfe2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
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