X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjob%2FJobQueueGroup.php;h=85f99b71676f66dfc5eefb6cef8b02d1b96d14c5;hb=bfc8d738edaf549444b631c1531f32669fdea57a;hp=8252633b41a3cc0153d53ad099e97e338b0ea312;hpb=d63121016d894e3fccf3308a26704472e69ec08f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/job/JobQueueGroup.php b/includes/job/JobQueueGroup.php index 8252633b41..85f99b7167 100644 --- a/includes/job/JobQueueGroup.php +++ b/includes/job/JobQueueGroup.php @@ -40,13 +40,14 @@ class JobQueueGroup { const TYPE_ANY = 2; // integer; any job const USE_CACHE = 1; // integer; use process or persistent cache + const USE_PRIORITY = 2; // integer; respect deprioritization const PROC_CACHE_TTL = 15; // integer; seconds const CACHE_VERSION = 1; // integer; cache version /** - * @param $wiki string Wiki ID + * @param string $wiki Wiki ID */ protected function __construct( $wiki ) { $this->wiki = $wiki; @@ -54,7 +55,7 @@ class JobQueueGroup { } /** - * @param $wiki string Wiki ID + * @param string $wiki Wiki ID * @return JobQueueGroup */ public static function singleton( $wiki = false ) { @@ -146,6 +147,9 @@ class JobQueueGroup { */ public function pop( $qtype = self::TYPE_DEFAULT, $flags = 0 ) { if ( is_string( $qtype ) ) { // specific job type + if ( ( $flags & self::USE_PRIORITY ) && $this->isQueueDeprioritized( $qtype ) ) { + return false; // back off + } $job = $this->get( $qtype )->pop(); if ( !$job ) { JobQueueAggregator::singleton()->notifyQueueEmpty( $this->wiki, $qtype ); @@ -167,6 +171,9 @@ class JobQueueGroup { shuffle( $types ); // avoid starvation foreach ( $types as $type ) { // for each queue... + if ( ( $flags & self::USE_PRIORITY ) && $this->isQueueDeprioritized( $type ) ) { + continue; // back off + } $job = $this->get( $type )->pop(); if ( $job ) { // found return $job; @@ -201,6 +208,25 @@ class JobQueueGroup { return $this->get( $job->getType() )->deduplicateRootJob( $job ); } + /** + * Wait for any slaves or backup queue servers to catch up. + * + * This does nothing for certain queue classes. + * + * @return void + * @throws MWException + */ + public function waitForBackups() { + global $wgJobTypeConf; + + wfProfileIn( __METHOD__ ); + // Try to avoid doing this more than once per queue storage medium + foreach ( $wgJobTypeConf as $type => $conf ) { + $this->get( $type )->waitForBackups(); + } + wfProfileOut( __METHOD__ ); + } + /** * Get the list of queue types * @@ -245,10 +271,15 @@ class JobQueueGroup { * @return bool */ public function isQueueDeprioritized( $type ) { + if ( $this->cache->has( 'isDeprioritized', $type, 5 ) ) { + return $this->cache->get( 'isDeprioritized', $type ); + } if ( $type === 'refreshLinks2' ) { // Don't keep converting refreshLinks2 => refreshLinks jobs if the // later jobs have not been done yet. This helps throttle queue spam. - return !$this->get( 'refreshLinks' )->isEmpty(); + $deprioritized = !$this->get( 'refreshLinks' )->isEmpty(); + $this->cache->set( 'isDeprioritized', $type, $deprioritized ); + return $deprioritized; } return false; }