From: Gergo Tisza Date: Wed, 7 May 2014 21:12:34 +0000 (+0000) Subject: Allow floating point values for $wgJobBackoffThrottling X-Git-Tag: 1.31.0-rc.0~15729^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=c1a60bfb8e2d8abcff0e0994e06aa9ac899b7fc9;p=lhc%2Fweb%2Fwiklou.git Allow floating point values for $wgJobBackoffThrottling Useful for jobs which take longer than a second to finish. Change-Id: I2e57d61fd67b97fbd593274b31e1bfada8f522f5 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c2818938ed..3ed71d1fd2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -6176,6 +6176,7 @@ $wgJobTypesExcludedFromDefaultQueue = array( 'AssembleUploadChunks', 'PublishSta * may have a variable number of work items, as is the case with batch jobs. * This is used by runJobs.php and not jobs run via $wgJobRunRate. * These settings should be global to all wikis. + * @var float[] */ $wgJobBackoffThrottling = array(); diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index f69a3a30b7..9b86e1b617 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -189,9 +189,11 @@ class RunJobs extends Maintenance { $seconds = 0; if ( $job->workItemCount() > 0 ) { - $seconds = floor( $job->workItemCount() / $itemsPerSecond ); - $remainder = $job->workItemCount() % $itemsPerSecond; - $seconds += ( mt_rand( 1, $itemsPerSecond ) <= $remainder ) ? 1 : 0; + $exactSeconds = $job->workItemCount() / $itemsPerSecond; + // use randomized rounding + $seconds = floor( $exactSeconds ); + $remainder = $exactSeconds - $seconds; + $seconds += ( mt_rand() / mt_getrandmax() < $remainder ) ? 1 : 0; } return (int)$seconds;