flush();
if ( $ret !== false ) {
$updatesDone[] = $origParams;
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
} else {
$updatesSkipped[] = array( $func, $params, $origParams );
}
foreach ( $res as $row ) {
$count = ( $count + 1 ) % 100;
if ( $count == 0 ) {
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication( array( 'wiki' => wfWikiID() ) );
}
$this->db->insert( 'templatelinks',
array(
// 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;
}
$catMembChange->triggerCategoryAddedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount % $batchSize ) == 0 ) {
$dbw->commit( __METHOD__, 'flush' );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
}
}
$catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
if ( $insertCount++ && ( $insertCount++ % $batchSize ) == 0 ) {
$dbw->commit( __METHOD__, 'flush' );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
}
}
}
// 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 ) ),
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;
}
$lockKey = wfWikiID() . '-activeusers';
if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
- return false; // exclusive update (avoids duplicate entries)
+ return; // exclusive update (avoids duplicate entries)
}
$nowUnix = time();
}
foreach ( array_chunk( $newRows, 500 ) as $rowBatch ) {
$dbw->insert( 'querycachetwo', $rowBatch, __METHOD__ );
- wfWaitForSlaves();
+ wfGetLBFactory()->waitForReplication();
}
}
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;
}
$this->db->commit();
- wfWaitForSlaves( false, false, $this->clusterName );
+ wfGetLBFactory()->waitForReplication();
}
}