X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJobRunner.php;h=a85613af4835b0e9cfdf6baef9c7149caf3397a1;hb=485f66f1;hp=db881d5eb91ff64b554a16cabdea4f8fcda731ec;hpb=20b0288ac360d791bd2af16586f91f62711c8a37;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index db881d5eb9..a85613af48 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -109,9 +109,9 @@ class JobRunner implements LoggerAwareInterface { $response = [ 'jobs' => [], 'reached' => 'none-ready' ]; - $type = isset( $options['type'] ) ? $options['type'] : false; - $maxJobs = isset( $options['maxJobs'] ) ? $options['maxJobs'] : false; - $maxTime = isset( $options['maxTime'] ) ? $options['maxTime'] : false; + $type = $options['type'] ?? false; + $maxJobs = $options['maxJobs'] ?? false; + $maxTime = $options['maxTime'] ?? false; $noThrottle = isset( $options['throttle'] ) && !$options['throttle']; // Bail if job type is invalid @@ -119,6 +119,7 @@ class JobRunner implements LoggerAwareInterface { $response['reached'] = 'none-possible'; return $response; } + // Bail out if DB is in read-only mode if ( wfReadOnly() ) { $response['reached'] = 'read-only'; @@ -126,6 +127,9 @@ class JobRunner implements LoggerAwareInterface { } $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + if ( $lbFactory->hasTransactionRound() ) { + throw new LogicException( __METHOD__ . ' called with an active transaction round.' ); + } // 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(); @@ -134,9 +138,6 @@ class JobRunner implements LoggerAwareInterface { return $response; } - // Flush any pending DB writes for sanity - $lbFactory->commitAll( __METHOD__ ); - // Catch huge single updates that lead to replica DB lag $trxProfiler = Profiler::instance()->getTransactionProfiler(); $trxProfiler->setLogger( LoggerFactory::getInstance( 'DBPerformance' ) ); @@ -170,7 +171,6 @@ class JobRunner implements LoggerAwareInterface { } else { $job = $group->pop( $type ); // job from a single queue } - $lbFactory->commitMasterChanges( __METHOD__ ); // flush any JobQueueDB writes if ( $job ) { // found a job ++$jobsPopped; @@ -193,7 +193,6 @@ class JobRunner implements LoggerAwareInterface { $info = $this->executeJob( $job, $lbFactory, $stats, $popTime ); if ( $info['status'] !== false || !$job->allowRetries() ) { $group->ack( $job ); // succeeded or job cannot be retried - $lbFactory->commitMasterChanges( __METHOD__ ); // flush any JobQueueDB writes } // Back off of certain jobs for a while (for throttling and for errors) @@ -291,7 +290,9 @@ class JobRunner implements LoggerAwareInterface { $jobStartTime = microtime( true ); try { $fnameTrxOwner = get_class( $job ) . '::run'; // give run() outer scope - $lbFactory->beginMasterChanges( $fnameTrxOwner ); + if ( !$job->hasExecutionFlag( $job::JOB_NO_EXPLICIT_TRX_ROUND ) ) { + $lbFactory->beginMasterChanges( $fnameTrxOwner ); + } $status = $job->run(); $error = $job->getLastError(); $this->commitMasterChanges( $lbFactory, $job, $fnameTrxOwner );