Made --maxtime a soft limit again
[lhc/web/wiklou.git] / maintenance / runJobs.php
index 9b86e1b..423ae61 100644 (file)
@@ -101,8 +101,6 @@ class RunJobs extends Maintenance {
                                ++$jobsRun;
                                $this->runJobsLog( $job->toString() . " STARTING" );
 
-                               // Set timer to stop the job if too much CPU time is used
-                               set_time_limit( $maxTime ? : 0 );
                                // Run the job...
                                wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
                                $t = microtime( true );
@@ -117,8 +115,6 @@ class RunJobs extends Maintenance {
                                }
                                $timeMs = intval( ( microtime( true ) - $t ) * 1000 );
                                wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
-                               // Disable the timer
-                               set_time_limit( 0 );
 
                                // Mark the job as done on success or when the job cannot be retried
                                if ( $status !== false || !$job->allowRetries() ) {
@@ -131,8 +127,11 @@ class RunJobs extends Maintenance {
                                        $this->runJobsLog( $job->toString() . " t=$timeMs good" );
                                }
 
-                               // Back off of certain jobs for a while
+                               // Back off of certain jobs for a while (for throttling and for errors)
                                $ttw = $this->getBackoffTimeToWait( $job );
+                               if ( $status === false && mt_rand( 0, 49 ) == 0 ) {
+                                       $ttw = max( $ttw, 30 );
+                               }
                                if ( $ttw > 0 ) {
                                        $jType = $job->getType();
                                        $backoffs[$jType] = isset( $backoffs[$jType] ) ? $backoffs[$jType] : 0;