Seb35 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/356880 )
Change subject: Better handling of jobs execution in post-connection shutdown ...................................................................... Better handling of jobs execution in post-connection shutdown In the postprocessing, some jobs can be executed but given the deferred updates were already "closed", any new DeferredUpdate were directly called (as explained by Krinkle on T165714), and the transactions opened by classical jobs are badly mixed with transactions (directly) executed by DeferredUpdates jobs, issuing a DBError, avoiding the job, which stays in a 'claimed' status even if failed. Quite similarly, some DeferredUpdates callables use JobQueueGroup::lazyPush so it is needed to really push the generated jobs. This change removes the run-immediately-deferred-updates behaviour even in the post-connection shutdown, and given there is a call to DeferredUpdates::doUpdates in JobRunner::execute it is not necessary to add another one and hence execution of Web jobs is more similar to execution of CLI jobs. In the same spirit to reconcile Web jobs and CLI jobs, the call to JobQueueGroup::pushLazyJobs is done in JobRunner::execute. Bug: T165714 Bug: T100085 Change-Id: I721e7167eca5b0b6227234fe516005243ab22388 (cherry picked from commit d80fca05e18d9654b8458ed6966c5d3c4991d88e) --- M includes/MediaWiki.php M includes/deferred/DeferredUpdates.php M includes/jobqueue/JobRunner.php 3 files changed, 4 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/80/356880/1 diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index aabaf30..f668717 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -889,7 +889,6 @@ // Do any deferred jobs DeferredUpdates::doUpdates( 'enqueue' ); - DeferredUpdates::setImmediateMode( true ); // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index 1ba6c1f..fd3a1af 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -52,8 +52,6 @@ private static $preSendUpdates = []; /** @var DeferrableUpdate[] Updates to be deferred until after request end */ private static $postSendUpdates = []; - /** @var bool Whether to just run updates in addUpdate() */ - private static $immediateMode = false; const ALL = 0; // all updates; in web requests, use only after flushing the output buffer const PRESEND = 1; // for updates that should run before flushing output buffer @@ -85,12 +83,6 @@ self::push( self::$preSendUpdates, $update ); } else { self::push( self::$postSendUpdates, $update ); - } - - if ( self::$immediateMode ) { - // No more explicit doUpdates() calls will happen, so run this now - self::doUpdates( 'run' ); - return; } // Try to run the updates now if in CLI mode and no transaction is active. @@ -137,9 +129,10 @@ /** * @param bool $value Whether to just immediately run updates in addUpdate() * @since 1.28 + * @deprecated 1.29 Causes issues in Web-executed jobs - see T165714 and T100085. */ public static function setImmediateMode( $value ) { - self::$immediateMode = (bool)$value; + wfDeprecated( __METHOD__, '1.29' ); } /** diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 0469eeb..aa8917c 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -277,6 +277,8 @@ $this->commitMasterChanges( $lbFactory, $job, $fnameTrxOwner ); // Run any deferred update tasks; doUpdates() manages transactions itself DeferredUpdates::doUpdates(); + // Push lazy jobs added by the job or its deferred udpates + JobQueueGroup::pushLazyJobs(); } catch ( Exception $e ) { MWExceptionHandler::rollbackMasterChangesAndLog( $e ); $status = false; -- To view, visit https://gerrit.wikimedia.org/r/356880 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I721e7167eca5b0b6227234fe516005243ab22388 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_28 Gerrit-Owner: Seb35 <se...@seb35.fr> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits