From: Aaron Schulz Date: Wed, 16 Dec 2015 22:43:12 +0000 (-0800) Subject: Avoid negative JobRunner time stats X-Git-Tag: 1.31.0-rc.0~8630^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_modifier.php?a=commitdiff_plain;h=867721324986febe21ecb27d5f2a38ab3dd88db1;p=lhc%2Fweb%2Fwiklou.git Avoid negative JobRunner time stats This can happen in sub-second cases with skew. It makes graphana tend to see -1 as the min for some time values. Change-Id: I4e39d8ac29f515fd76548f1a7b64d71a03064407 --- diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index b121dfe57e..5666415e47 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -201,14 +201,14 @@ class JobRunner implements LoggerAwareInterface { // Record how long jobs wait before getting popped $readyTs = $job->getReadyTimestamp(); if ( $readyTs ) { - $pickupDelay = $popTime - $readyTs; + $pickupDelay = max( 0, $popTime - $readyTs ); $stats->timing( 'jobqueue.pickup_delay.all', 1000 * $pickupDelay ); $stats->timing( "jobqueue.pickup_delay.$jType", 1000 * $pickupDelay ); } // Record root job age for jobs being run $root = $job->getRootJobParams(); if ( $root['rootJobTimestamp'] ) { - $age = $popTime - wfTimestamp( TS_UNIX, $root['rootJobTimestamp'] ); + $age = max( 0, $popTime - wfTimestamp( TS_UNIX, $root['rootJobTimestamp'] ) ); $stats->timing( "jobqueue.pickup_root_age.$jType", 1000 * $age ); } // Track the execution time for jobs