From: Roan Kattouw Date: Sun, 20 Mar 2011 16:52:57 +0000 (+0000) Subject: (bug 27336) Add $wgJobTypesExcludedFromDefaultQueue for job types that aren't suppose... X-Git-Tag: 1.31.0-rc.0~31295 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=45f9da8ad700d5ee278f3db84e555b41ca26a138;p=lhc%2Fweb%2Fwiklou.git (bug 27336) Add $wgJobTypesExcludedFromDefaultQueue for job types that aren't supposed to be run by 'normal' job runners. Modified patch by Michael Dale --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e1c18060fa..17ad00a2c9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4651,6 +4651,18 @@ $wgJobClasses = array( */ $wgExcludeFromThumbnailPurge = array(); +/** + + * Jobs that must be explicitly requested, i.e. aren't run by job runners unless special flags are set. + * + * These can be: + * - Very long-running jobs. + * - Jobs that you would never want to run as part of a page rendering request. + * - Jobs that you want to run on specialized machines ( like transcoding, or a particular + * machine on your cluster has 'outside' web access you could restrict uploadFromUrl ) + */ +$wgJobTypesExcludedFromDefaultQueue = array(); + /** * Additional functions to be performed with updateSpecialPages. * Expensive Querypages are already updated. diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index 34f23b466d..90bc98c9e7 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -95,6 +95,7 @@ abstract class Job { * @return Job or false if there's no jobs */ static function pop( $offset = 0 ) { + global $wgJobTypesExcludedFromDefaultQueue; wfProfileIn( __METHOD__ ); $dbr = wfGetDB( DB_SLAVE ); @@ -105,16 +106,23 @@ abstract class Job { NB: If random fetch previously was used, offset will always be ahead of few entries */ - - $row = $dbr->selectRow( 'job', '*', "job_id >= ${offset}", __METHOD__, - array( 'ORDER BY' => 'job_id', 'LIMIT' => 1 ) ); + $conditions = array(); + if ( count( $wgJobTypesExcludedFromDefaultQueue ) != 0 ) { + foreach ( $wgJobTypesExcludedFromDefaultQueue as $cmdType ) { + $conditions[] = "job_cmd != " . $dbr->addQuotes( $cmdType ); + } + } + $offset = intval( $offset ); + $row = $dbr->selectRow( 'job', '*', array_merge( $conditions, array( "job_id >= $offset" ) ) , __METHOD__, + array( 'ORDER BY' => 'job_id', 'LIMIT' => 1 ) + ); // Refetching without offset is needed as some of job IDs could have had delayed commits // and have lower IDs than jobs already executed, blame concurrency :) // if ( $row === false ) { if ( $offset != 0 ) { - $row = $dbr->selectRow( 'job', '*', '', __METHOD__, + $row = $dbr->selectRow( 'job', '*', $conditions, __METHOD__, array( 'ORDER BY' => 'job_id', 'LIMIT' => 1 ) ); }