maintenance/waitForSlave.php still calls the old prototype.
Most instances were replaced with
sed -i 's/wfWaitForSlaves( [0-9]* );/wfWaitForSlaves();/' ./maintenance/initEditCount.php ./maintenance/updateRestrictions.php ./maintenance/updateSpecialPages.php ./maintenance/importDump.php ./maintenance/moveBatch.php ./maintenance/storage/resolveStubs.php ./maintenance/storage/trackBlobs.php ./maintenance/storage/fixBug20757.php ./maintenance/storage/moveToExternal.php ./maintenance/storage/compressOld.inc ./maintenance/populateSha1.php ./maintenance/deleteDefaultMessages.php ./maintenance/migrateUserGroup.php ./maintenance/importImages.php ./maintenance/runJobs.php ./maintenance/archives/upgradeLogging.php ./maintenance/deleteBatch.php ./maintenance/populateLogSearch.php ./maintenance/populateLogUsertext.php ./maintenance/gearman/gearmanWorker.php ./maintenance/populateRevisionLength.php ./maintenance/refreshLinks.php ./maintenance/deleteSelfExternals.php ./maintenance/upgrade1_5.php ./maintenance/rebuildFileCache.php ./includes/job/RefreshLinksJob.php ./includes/installer/MysqlUpdater.php ./maintenance/convertUserOptions.php ./maintenance/populateParentId.php ./maintenance/runBatchedQuery.php ./maintenance/upgrade1_5.php ./maintenance/waitForSlave.php ./maintenance/populateCategory.php ./maintenance/importImages.php
}
/**
- * Sleep until the worst slave's replication lag is less than or equal to
- * $maxLag, in seconds. Use this when updating very large numbers of rows, as
+ * Modern version of wfWaitForSlaves(). Instead of looking at replication lag
+ * and waiting for it to go down, this waits for the slaves to catch up to the
+ * master position. Use this when updating very large numbers of rows, as
* in maintenance scripts, to avoid causing too much lag. Of course, this is
* a no-op if there are no slaves.
- *
- * Every time the function has to wait for a slave, it will print a message to
- * that effect (and then sleep for a little while), so it's probably not best
- * to use this outside maintenance scripts in its present form.
- *
- * @param $maxLag Integer
+ *
+ * @param $maxLag Integer (deprecated)
* @param $wiki mixed Wiki identifier accepted by wfGetLB
* @return null
*/
-function wfWaitForSlaves( $maxLag, $wiki = false ) {
- if( $maxLag ) {
- $lb = wfGetLB( $wiki );
- list( $host, $lag ) = $lb->getMaxLag( $wiki );
- while( $lag > $maxLag ) {
- wfSuppressWarnings();
- $name = gethostbyaddr( $host );
- wfRestoreWarnings();
- if( $name !== false ) {
- $host = $name;
- }
- print "Waiting for $host (lagged $lag seconds)...\n";
- sleep( $maxLag );
- list( $host, $lag ) = $lb->getMaxLag();
- }
- }
-}
-
-/**
- * Modern version of wfWaitForSlaves(). Instead of looking at replication lag
- * and waiting for it to go down, this waits for the slaves to catch up to the
- * master position. This is much better for lag control than wfWaitForSlaves()
- */
-function wfWaitForSlaves_masterPos() {
+function wfWaitForSlaves( $maxLag = false, $wiki = false ) {
$lb = wfGetLB();
// bug 27975 - Don't try to wait for slaves if there are none
// Prevents permission error when getting master position
foreach ( $res as $row ) {
$count = ( $count + 1 ) % 100;
if ( $count == 0 ) {
- wfWaitForSlaves( 10 );
+ wfWaitForSlaves();
}
$this->db->insert( 'templatelinks',
array(
$update = new LinksUpdate( $title, $parserOutput, false );
$update->doUpdate();
wfProfileOut( __METHOD__.'-update' );
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
wfProfileOut( __METHOD__ );
$this->dbw->insert( $dstTable, $batch, __METHOD__ );
$numRowsCopied += count( $batch );
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
echo "Copied $numRowsCopied rows\n";
}
$id = $this->convertOptionBatch( $res, $dbw );
$dbw->commit();
- wfWaitForSlaves( 1 );
+ wfWaitForSlaves();
if ( $id )
$this->output( "--Converted to ID $id\n" );
if ( $interval ) {
sleep( $interval );
}
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
}
}
foreach ( $res as $row ) {
if ( function_exists( 'wfWaitForSlaves' ) ) {
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$dbw->ping();
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
$this->output( "Deleting self externals from $wgServer\n" );
$db = wfGetDB( DB_MASTER );
while ( 1 ) {
- wfWaitForSlaves( 2 );
+ wfWaitForSlaves();
$db->commit();
$q = $db->limitResult( "DELETE /* deleteSelfExternals */ FROM externallinks WHERE el_to"
. $db->buildLike( $wgServer . '/', $db->anyString() ), $this->mBatchSize );
$interval = 5;
$now = time();
if ( $now - $lastSleep >= $interval ) {
- wfWaitForSlaves( $interval );
+ wfWaitForSlaves();
$lastSleep = $now;
}
return false;
$this->progress( "$this->revCount ($revrate revs/sec)" );
}
}
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
// XXX: Don't let deferred jobs array get absurdly large (bug 24375)
wfDoUpdates( 'commit' );
}
$article = new Article( $title );
echo "\nWaiting for slaves...\n";
// Wait for slaves.
- sleep( 2.0 );
- wfWaitForSlaves( 1.0 );
+ sleep( 2.0 ); # Why this sleep?
+ wfWaitForSlaves();
echo( "\nSetting image restrictions ... " );
if ( $article->updateRestrictions( $restrictions ) )
$delta,
$rate ) );
- wfWaitForSlaves( 10 );
+ wfWaitForSlaves();
}
} else {
// Subselect should work on modern MySQLs etc
$dbw->commit();
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$this->output( "Done! $count user(s) in group '$oldGroup' are now in '$newGroup' instead.\n" );
}
if ( $interval ) {
sleep( $interval );
}
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
}
}
++$i;
if ( !( $i % self::REPORTING_INTERVAL ) ) {
$this->output( "$name\n" );
- wfWaitForSlaves( $maxlag );
+ wfWaitForSlaves();
}
usleep( $throttle * 1000 );
}
}
$blockStart += self::LOG_SEARCH_BATCH_SIZE;
$blockEnd += self::LOG_SEARCH_BATCH_SIZE;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
if ( $db->insert(
'updatelog',
$db->commit();
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
if ( $db->insert(
'updatelog',
}
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$logged = $db->insert( 'updatelog',
array( 'ul_key' => 'populate rev_parent_id' ),
}
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$logged = $db->insert( 'updatelog',
array( 'ul_key' => 'populate rev_len' ),
foreach ( $res as $row ) {
if ( $i % 100 == 0 ) {
$this->output( sprintf( "Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100 ) );
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$file = wfLocalFile( $row->img_name );
if ( !$file ) {
}
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$this->output( "Done!\n" );
foreach ( $res as $row ) {
if ( !( ++$i % $reportingInterval ) ) {
$this->output( "$i\n" );
- wfWaitForSlaves( $maxLag );
+ wfWaitForSlaves();
}
$this->fixRedirect( $row->page_id );
}
foreach ( $res as $row ) {
if ( !( ++$i % $reportingInterval ) ) {
$this->output( "$i\n" );
- wfWaitForSlaves( $maxLag );
+ wfWaitForSlaves();
}
if ( $redirectsOnly ) {
$this->fixRedirect( $row->page_id );
if ( !( $id % $reportingInterval ) ) {
$this->output( "$id\n" );
- wfWaitForSlaves( $maxLag );
+ wfWaitForSlaves();
}
$this->fixRedirect( $id );
}
if ( !( $id % $reportingInterval ) ) {
$this->output( "$id\n" );
- wfWaitForSlaves( $maxLag );
+ wfWaitForSlaves();
}
self::fixLinksFromArticle( $id );
}
* @author Merlijn van Deen <valhallasw@arctus.nl>
*/
private function deleteLinksFromNonexistent( $maxLag = 0, $batchSize = 100 ) {
- wfWaitForSlaves( $maxLag );
+ wfWaitForSlaves();
$dbw = wfGetDB( DB_MASTER );
$counter++;
$list[] = $row->$field;
if ( ( $counter % $batchSize ) == 0 ) {
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
$dbw->delete( $table, array( $field => $list ), __METHOD__ );
$this->output( $counter . ".." );
$dbw->query( $query, __METHOD__ );
$affected = $dbw->affectedRows();
$this->output( "$affected rows\n" );
- wfWaitForSlaves_masterPos();
+ wfWaitForSlaves();
} while ( $affected > 0 );
}
if ( !$job )
break;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
$t = microtime( true );
$offset = $job->id;
$status = $job->run();
#$conds[] = 'page_id=rev_page AND rev_id != page_latest';
for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) {
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
# Wake up
$dbr->ping();
print "/";
$dbw->commit();
$i += $thisChunkSize;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
print "\n";
}
static $iteration = 0;
++$iteration;
if ( ++$iteration > 50 == 0 ) {
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
$iteration = 0;
}
}
if ( !( $block % REPORTING_INTERVAL ) ) {
print "oldid=$blockStart, moved=$numMoved\n";
- wfWaitForSlaves( 2 );
+ wfWaitForSlaves();
}
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ),
$numBlocks = intval( $maxID / $blockSize ) + 1;
for ( $b = 0; $b < $numBlocks; $b++ ) {
- wfWaitForSlaves( 2 );
+ wfWaitForSlaves();
printf( "%5.2f%%\n", $b / $numBlocks * 100 );
$start = intval( $maxID / $numBlocks ) * $b + 1;
if ( $batchesDone >= $this->reportingInterval ) {
$batchesDone = 0;
echo "$startId / $endId\n";
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
}
echo "Found $rowsInserted revisions\n";
if ( $batchesDone >= $this->reportingInterval ) {
$batchesDone = 0;
echo "$startId / $endId\n";
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
}
echo "Found $rowsInserted orphan text rows\n";
}
$blockStart += $this->mBatchSize - 1;
$blockEnd += $this->mBatchSize - 1;
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
$this->output( "...removing dead rows from page_restrictions\n" );
// Kill any broken rows from previous imports
}
$this->output( sprintf( "completed in %.2fs\n", $seconds ) );
# Wait for the slave to catch up
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
}
// This is needed to initialise $wgQueryPages
$dbw->commit();
}
# Wait for the slave to catch up
- wfWaitForSlaves( 5 );
+ wfWaitForSlaves();
} else {
$this->output( "cheap, skipped\n" );
}
$this->cleanupSwaps = array();
$this->emailAuth = false; # don't preauthenticate emails
- $this->maxLag = 10; # if slaves are lagged more than 10 secs, wait
$this->step = $this->getOption( 'step', null );
}
*/
function insertChunk( &$chunk ) {
// Give slaves a chance to catch up
- wfWaitForSlaves( $this->maxLag );
+ wfWaitForSlaves();
$this->dbw->insert( $this->chunkTable, $chunk, $this->chunkFunction, $this->chunkOptions );
}