X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJobRunner.php;h=21d8c7e8af679c0fe661d727e7bdf39c97fe7cf8;hb=434015880aab5b155cc7edd6fcddf1883d0395eb;hp=1e8316795c111e54527a349b8f91d93581613267;hpb=69286527352e8f7b59a4b78adc327b8336de9312;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 1e8316795c..21d8c7e8af 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -23,7 +23,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Logger\LoggerFactory; -use Liuggio\StatsdClient\Factory\StatsdDataFactory; +use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Wikimedia\ScopedCallback; @@ -131,7 +131,7 @@ class JobRunner implements LoggerAwareInterface { } // Bail out if there is too much DB lag. // This check should not block as we want to try other wiki queues. - list( , $maxLag ) = $lbFactory->getMainLB( wfWikiID() )->getMaxLag(); + list( , $maxLag ) = $lbFactory->getMainLB()->getMaxLag(); if ( $maxLag >= self::MAX_ALLOWED_LAG ) { $response['reached'] = 'replica-lag-limit'; return $response; @@ -265,13 +265,13 @@ class JobRunner implements LoggerAwareInterface { } /** - * @param Job $job + * @param RunnableJob $job * @param LBFactory $lbFactory - * @param StatsdDataFactory $stats + * @param StatsdDataFactoryInterface $stats * @param float $popTime * @return array Map of status/error/timeMs */ - private function executeJob( Job $job, LBFactory $lbFactory, $stats, $popTime ) { + private function executeJob( RunnableJob $job, LBFactory $lbFactory, $stats, $popTime ) { $jType = $job->getType(); $msg = $job->toString() . " STARTING"; $this->logger->debug( $msg, [ @@ -290,8 +290,6 @@ class JobRunner implements LoggerAwareInterface { $status = $job->run(); $error = $job->getLastError(); $this->commitMasterChanges( $lbFactory, $job, $fnameTrxOwner ); - // Important: this must be the last deferred update added (T100085, T154425) - DeferredUpdates::addCallableUpdate( [ JobQueueGroup::class, 'pushLazyJobs' ] ); // Run any deferred update tasks; doUpdates() manages transactions itself DeferredUpdates::doUpdates(); } catch ( Exception $e ) { @@ -369,11 +367,11 @@ class JobRunner implements LoggerAwareInterface { } /** - * @param Job $job + * @param RunnableJob $job * @return int Seconds for this runner to avoid doing more jobs of this type * @see $wgJobBackoffThrottling */ - private function getBackoffTimeToWait( Job $job ) { + private function getBackoffTimeToWait( RunnableJob $job ) { $throttling = $this->config->get( 'JobBackoffThrottling' ); if ( !isset( $throttling[$job->getType()] ) || $job instanceof DuplicateJob ) { @@ -528,16 +526,16 @@ class JobRunner implements LoggerAwareInterface { * $wgJobSerialCommitThreshold for more. * * @param LBFactory $lbFactory - * @param Job $job + * @param RunnableJob $job * @param string $fnameTrxOwner * @throws DBError */ - private function commitMasterChanges( LBFactory $lbFactory, Job $job, $fnameTrxOwner ) { + private function commitMasterChanges( LBFactory $lbFactory, RunnableJob $job, $fnameTrxOwner ) { $syncThreshold = $this->config->get( 'JobSerialCommitThreshold' ); $time = false; - $lb = $lbFactory->getMainLB( wfWikiID() ); - if ( $syncThreshold !== false && $lb->getServerCount() > 1 ) { + $lb = $lbFactory->getMainLB(); + if ( $syncThreshold !== false && $lb->hasStreamingReplicaServers() ) { // Generally, there is one master connection to the local DB $dbwSerial = $lb->getAnyOpenConnection( $lb->getWriterIndex() ); // We need natively blocking fast locks