aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2016-01-20 09:23:46 -0800
committerTim Starling <tstarling@wikimedia.org>2016-01-28 03:00:08 +0000
commit3a15ecebea7c560e01f81b7145f2cc32bb167c5f (patch)
treea64d58c8a23fa09f3ec170ef18e2da8e2e5a1af2 /includes
parent964e47251a5c917bfb868b099039c2d0ddb4efdf (diff)
downloadmediawikicore-3a15ecebea7c560e01f81b7145f2cc32bb167c5f.tar.gz
mediawikicore-3a15ecebea7c560e01f81b7145f2cc32bb167c5f.zip
Migrate callers to waitForReplication()
Change-Id: I7b2b13b9315891561d2d8cc04a12ecad2dc73d70
Diffstat (limited to 'includes')
-rw-r--r--includes/installer/DatabaseUpdater.php2
-rw-r--r--includes/installer/MysqlUpdater.php2
-rw-r--r--includes/jobqueue/JobRunner.php7
-rw-r--r--includes/jobqueue/jobs/CategoryMembershipChangeJob.php4
-rw-r--r--includes/jobqueue/jobs/HTMLCacheUpdateJob.php2
-rw-r--r--includes/jobqueue/jobs/RecentChangesUpdateJob.php8
-rw-r--r--includes/objectcache/SqlBagOStuff.php7
-rw-r--r--includes/utils/BatchRowWriter.php2
8 files changed, 23 insertions, 11 deletions
diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php
index 904fde83dc0a..61c3002fa8f7 100644
--- a/includes/installer/DatabaseUpdater.php
+++ b/includes/installer/DatabaseUpdater.php
@@ -456,7 +456,7 @@ abstract class DatabaseUpdater {
flush();
if ( $ret !== false ) {
$updatesDone[] = $origParams;
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
} else {
$updatesSkipped[] = array( $func, $params, $origParams );
}
diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php
index 4813beabe533..10fed319f137 100644
--- a/includes/installer/MysqlUpdater.php
+++ b/includes/installer/MysqlUpdater.php
@@ -836,7 +836,7 @@ class MysqlUpdater extends DatabaseUpdater {
foreach ( $res as $row ) {
$count = ( $count + 1 ) % 100;
if ( $count == 0 ) {
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication( array( 'wiki' => wfWikiID() ) );
}
$this->db->insert( 'templatelinks',
array(
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index 4ab9f5ad2e21..39193187cfc5 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -208,7 +208,12 @@ class JobRunner implements LoggerAwareInterface {
// other wikis in the farm (on different masters) get a chance.
$timePassed = microtime( true ) - $lastCheckTime;
if ( $timePassed >= self::LAG_CHECK_PERIOD || $timePassed < 0 ) {
- if ( !wfWaitForSlaves( $lastCheckTime, false, '*', self::MAX_ALLOWED_LAG ) ) {
+ try {
+ wfGetLBFactory()->waitForReplication( array(
+ 'ifWritesSince' => $lastCheckTime,
+ 'timeout' => self::MAX_ALLOWED_LAG
+ ) );
+ } catch ( DBReplicationWaitError $e ) {
$response['reached'] = 'slave-lag-limit';
break;
}
diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
index c9e20a9beac7..98c87a5ace91 100644
--- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
+++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php
@@ -169,7 +169,7 @@ class CategoryMembershipChangeJob extends Job {
$catMembChange->triggerCategoryAddedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount % $batchSize ) == 0 ) {
$dbw->commit( __METHOD__, 'flush' );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
}
}
@@ -178,7 +178,7 @@ class CategoryMembershipChangeJob extends Job {
$catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount++ % $batchSize ) == 0 ) {
$dbw->commit( __METHOD__, 'flush' );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
}
}
}
diff --git a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
index df0a66e409b8..0d48cb3858df 100644
--- a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
+++ b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php
@@ -120,7 +120,7 @@ class HTMLCacheUpdateJob extends Job {
// Check $wgUpdateRowsPerQuery for sanity; batch jobs are sized by that already.
foreach ( array_chunk( $pageIds, $wgUpdateRowsPerQuery ) as $batch ) {
$dbw->commit( __METHOD__, 'flush' );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
$dbw->update( 'page',
array( 'page_touched' => $dbw->timestamp( $touchTimestamp ) ),
diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
index d6fa26b81fcb..0685299026f0 100644
--- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php
+++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php
@@ -98,7 +98,9 @@ class RecentChangesUpdateJob extends Job {
if ( count( $rcIds ) === $batchSize ) {
// There might be more, so try waiting for slaves
- if ( !wfWaitForSlaves( null, false, false, /* $timeout = */ 3 ) ) {
+ try {
+ wfGetLBFactory()->waitForReplication( array( 'timeout' => 3 ) );
+ } catch ( DBReplicationWaitError $e ) {
// Another job will continue anyway
break;
}
@@ -125,7 +127,7 @@ class RecentChangesUpdateJob extends Job {
$lockKey = wfWikiID() . '-activeusers';
if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
- return false; // exclusive update (avoids duplicate entries)
+ return; // exclusive update (avoids duplicate entries)
}
$nowUnix = time();
@@ -203,7 +205,7 @@ class RecentChangesUpdateJob extends Job {
}
foreach ( array_chunk( $newRows, 500 ) as $rowBatch ) {
$dbw->insert( 'querycachetwo', $rowBatch, __METHOD__ );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
}
}
diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php
index 57765190e9af..0e3c9ebbf9e1 100644
--- a/includes/objectcache/SqlBagOStuff.php
+++ b/includes/objectcache/SqlBagOStuff.php
@@ -735,7 +735,12 @@ class SqlBagOStuff extends BagOStuff {
protected function waitForSlaves() {
if ( !$this->serverInfos ) {
// Main LB is used; wait for any slaves to catch up
- return wfWaitForSlaves( null, false, false, $this->syncTimeout );
+ try {
+ wfGetLBFactory()->waitForReplication( array( 'wiki' => wfWikiID() ) );
+ return true;
+ } catch ( DBReplicationWaitError $e ) {
+ return false;
+ }
} else {
// Custom DB server list; probably doesn't use replication
return true;
diff --git a/includes/utils/BatchRowWriter.php b/includes/utils/BatchRowWriter.php
index 13cab5bd2b68..ffb7053b383f 100644
--- a/includes/utils/BatchRowWriter.php
+++ b/includes/utils/BatchRowWriter.php
@@ -66,6 +66,6 @@ class BatchRowWriter {
}
$this->db->commit();
- wfWaitForSlaves( false, false, $this->clusterName );
+ wfGetLBFactory()->waitForReplication();
}
}