From: Marius Hoch Date: Sun, 22 Feb 2015 21:08:48 +0000 (+0100) Subject: Wait for slaves in RecentChangesUpdateJob X-Git-Tag: 1.31.0-rc.0~12306^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=53d0c94c2f1131394c98e9f5c9d29defa3ac67ca;p=lhc%2Fweb%2Fwiklou.git Wait for slaves in RecentChangesUpdateJob Change-Id: Iba8dca2f92d1c9ba2e5ab064aae828e4d88779bb --- diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php index b54ecfdc16..fb10c15467 100644 --- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php +++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php @@ -64,6 +64,7 @@ class RecentChangesUpdateJob extends Job { 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 @@ class RecentChangesUpdateJob extends Job { '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__ );