From a8590172c8b4898f0dc07203104c92b3835aadee Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 8 Oct 2015 00:09:08 -0700 Subject: [PATCH] Make DeferredUpdates::doUpdates always commit per task * All callers are either using commit already or would be fine using it (e.g. Maintenance scripts and JobRunner that have no real transaction open). Change-Id: I9f54b27619da6dac2cb63d255995aabc4ee78002 --- includes/MediaWiki.php | 2 +- includes/deferred/DeferredUpdates.php | 14 +++++++++----- maintenance/doMaintenance.php | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 7ae7c35b64..676108c757 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', 'enqueue' ); + DeferredUpdates::doUpdates( 'enqueue' ); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index 8f8ed2ed07..0194a61e0b 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -94,11 +94,17 @@ 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 + * @param string $oldMode Unused */ - public static function doUpdates( $commit = '', $mode = 'run' ) { + public static function doUpdates( $mode = 'run', $oldMode = '' ) { + // B/C for ( $commit, $mode ) args + $mode = $oldMode ?: $mode; + if ( $mode === 'commit' ) { + $mode = 'run'; + } + $updates = self::$updates; while ( count( $updates ) ) { @@ -121,9 +127,7 @@ class DeferredUpdates { foreach ( $otherUpdates as $update ) { try { $update->doUpdate(); - if ( $commit === 'commit' ) { - wfGetLBFactory()->commitMasterChanges(); - } + wfGetLBFactory()->commitMasterChanges(); } catch ( Exception $e ) { // We don't want exceptions thrown during deferred updates to // be reported to the user since the output is already sent. diff --git a/maintenance/doMaintenance.php b/maintenance/doMaintenance.php index 4b9ad9c22d..e66b7293c0 100644 --- a/maintenance/doMaintenance.php +++ b/maintenance/doMaintenance.php @@ -106,7 +106,7 @@ $maintenance->execute(); $maintenance->globals(); // Perform deferred updates. -DeferredUpdates::doUpdates( 'commit' ); +DeferredUpdates::doUpdates(); // log profiling info wfLogProfilingData(); -- 2.20.1