X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJobRunner.php;h=709a67b01fc5176cb45af70b1c70be11e6f1f892;hb=a389d94551f1ece9112c66bf8a53f66d3c15c0b2;hp=21d8c7e8af679c0fe661d727e7bdf39c97fe7cf8;hpb=6cfb2e3d7a2b96d5041312fcec88248bb46573d7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 21d8c7e8af..709a67b01f 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -279,16 +279,26 @@ class JobRunner implements LoggerAwareInterface { ] ); $this->debugCallback( $msg ); + // Clear out title cache data from prior snapshots + // (e.g. from before JobRunner was invoked in this process) + MediaWikiServices::getInstance()->getLinkCache()->clear(); + // Run the job... $rssStart = $this->getMaxRssKb(); $jobStartTime = microtime( true ); try { $fnameTrxOwner = get_class( $job ) . '::run'; // give run() outer scope - if ( !$job->hasExecutionFlag( $job::JOB_NO_EXPLICIT_TRX_ROUND ) ) { - $lbFactory->beginMasterChanges( $fnameTrxOwner ); + // Flush any pending changes left over from an implicit transaction round + if ( $job->hasExecutionFlag( $job::JOB_NO_EXPLICIT_TRX_ROUND ) ) { + $lbFactory->commitMasterChanges( $fnameTrxOwner ); // new implicit round + } else { + $lbFactory->beginMasterChanges( $fnameTrxOwner ); // new explicit round } + // Clear any stale REPEATABLE-READ snapshots from replica DB connections + $lbFactory->flushReplicaSnapshots( $fnameTrxOwner ); $status = $job->run(); $error = $job->getLastError(); + // Commit all pending changes from this job $this->commitMasterChanges( $lbFactory, $job, $fnameTrxOwner ); // Run any deferred update tasks; doUpdates() manages transactions itself DeferredUpdates::doUpdates(); @@ -299,17 +309,11 @@ class JobRunner implements LoggerAwareInterface { } // Always attempt to call teardown() even if Job throws exception. try { - $job->teardown( $status ); + $job->tearDown( $status ); } catch ( Exception $e ) { MWExceptionHandler::logException( $e ); } - // Commit all outstanding connections that are in a transaction - // to get a fresh repeatable read snapshot on every connection. - // Note that jobs are still responsible for handling replica DB lag. - $lbFactory->flushReplicaSnapshots( __METHOD__ ); - // Clear out title cache data from prior snapshots - MediaWikiServices::getInstance()->getLinkCache()->clear(); $timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 ); $rssEnd = $this->getMaxRssKb();