Merge "Allow floating point values for $wgJobBackoffThrottling"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 13 May 2014 20:29:25 +0000 (20:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 13 May 2014 20:29:25 +0000 (20:29 +0000)
includes/DefaultSettings.php
maintenance/runJobs.php

index 64512c8..e011d4a 100644 (file)
@@ -6186,6 +6186,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();
 
index f69a3a3..9b86e1b 100644 (file)
@@ -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;