From: Aaron Schulz Date: Wed, 30 Sep 2015 19:30:22 +0000 (-0700) Subject: Made LinksUpdate on edit use the job queue X-Git-Tag: 1.31.0-rc.0~9480^2 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=1846e2dc15e957c557efad75f4e99f5a73c38aaa;p=lhc%2Fweb%2Fwiklou.git Made LinksUpdate on edit use the job queue * LinksUpdate is now an EnqueueableDataUpdate and can yeild a prioritzed refreshLinks job. * DeferredUpdates::runUpdates() now takes an enqueue flag to try to use jobs. This is set in restInPeace(). Updates that change many links will be less likely to increase lag, as the runners are more strict about that. * Also made the LinksDeletionUpdate job enqueue happen post-send on page deletion for consistency Bug: T95501 Change-Id: I8863caef9c8f03234699d33e4d47d2310a0c8446 --- diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 418ed8b008..aee6ee1b99 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -690,7 +690,7 @@ class MediaWiki { Profiler::instance()->getTransactionProfiler()->resetExpectations(); // Do any deferred jobs - DeferredUpdates::doUpdates( 'commit' ); + DeferredUpdates::doUpdates( 'commit', 'enqueue' ); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index 8b3582db69..53312cdc8d 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -95,9 +95,10 @@ class DeferredUpdates { * Do any deferred updates and clear the list * * @param string $commit Set to 'commit' to commit after every update to + * @param string $mode Use "enqueue" to use the job queue when possible [Default: run] * prevent lock contention */ - public static function doUpdates( $commit = '' ) { + public static function doUpdates( $commit = '', $mode = 'run' ) { $updates = self::$updates; while ( count( $updates ) ) { @@ -115,12 +116,11 @@ class DeferredUpdates { } // Delegate DataUpdate execution to the DataUpdate class - DataUpdate::runUpdates( $dataUpdates, 'run' ); + DataUpdate::runUpdates( $dataUpdates, $mode ); // Execute the non-DataUpdate tasks foreach ( $otherUpdates as $update ) { try { $update->doUpdate(); - if ( $commit === 'commit' ) { wfGetLBFactory()->commitMasterChanges(); } diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index be5aff3b13..d99687026a 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -25,7 +25,7 @@ * * @todo document (e.g. one-sentence top-level class description). */ -class LinksUpdate extends SqlDataUpdate { +class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate { // @todo make members protected, but make sure extensions don't break /** @var int Page ID of the article linked from */ @@ -934,4 +934,16 @@ class LinksUpdate extends SqlDataUpdate { ); } } + + public function getAsJobSpecification() { + return array( + 'wiki' => $this->mDb->getWikiID(), + 'job' => new JobSpecification( + 'refreshLinks', + array( 'prioritize' => true ), + array( 'removeDuplicates' => true ), + $this->getTitle() + ) + ); + } } diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index e47e06cb49..1ded678f16 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -2935,10 +2935,9 @@ class WikiPage implements Page, IDBAccessObject { // Delete pagelinks, update secondary indexes, etc $updates = $this->getDeletionUpdates( $content ); - // Make sure an enqueued jobs run after commit so they see the deletion - wfGetDB( DB_MASTER )->onTransactionIdle( function() use ( $updates ) { - DataUpdate::runUpdates( $updates, 'enqueue' ); - } ); + foreach ( $updates as $update ) { + DeferredUpdates::addUpdate( $update ); + } // Reparse any pages transcluding this page LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );