Aaron Schulz has submitted this change and it was merged.

Change subject: Wait for slaves in RecentChangesUpdateJob
......................................................................


Wait for slaves in RecentChangesUpdateJob

Change-Id: Iba8dca2f92d1c9ba2e5ab064aae828e4d88779bb
(cherry picked from commit 53d0c94c2f1131394c98e9f5c9d29defa3ac67ca)
---
M includes/jobqueue/jobs/RecentChangesUpdateJob.php
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Aaron Schulz: Verified; Looks good to me, approved



diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php 
b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
index b54ecfd..fb10c15 100644
--- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php
+++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
@@ -64,6 +64,7 @@
                if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
                        return; // already in progress
                }
+               $batchSize = 100; // Avoid slave lag
 
                $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
                do {
@@ -71,13 +72,21 @@
                                'rc_id',
                                array( 'rc_timestamp < ' . $dbw->addQuotes( 
$cutoff ) ),
                                __METHOD__,
-                               array( 'LIMIT' => 100 ) // avoid slave lag
+                               array( 'LIMIT' => $batchSize )
                        );
                        if ( $rcIds ) {
                                $dbw->delete( 'recentchanges', array( 'rc_id' 
=> $rcIds ), __METHOD__ );
                        }
                        // No need for this to be in a transaction.
                        $dbw->commit( __METHOD__, 'flush' );
+
+                       if ( count( $rcIds ) === $batchSize ) {
+                               // There might be more, so try waiting for 
slaves
+                               if ( !wfWaitForSlaves( null, false, false, /* 
$timeout = */ 3 ) ) {
+                                       // Another job will continue anyway
+                                       break;
+                               }
+                       }
                } while ( $rcIds );
 
                $dbw->unlock( $lockKey, __METHOD__ );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iba8dca2f92d1c9ba2e5ab064aae828e4d88779bb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.25wmf17
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to