From 867721324986febe21ecb27d5f2a38ab3dd88db1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 16 Dec 2015 14:43:12 -0800 Subject: [PATCH] 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 --- includes/jobqueue/JobRunner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.20.1