: null;
}
+ /**
+ * @return int|null UNIX timestamp of when the job was queued, or null
+ * @since 1.26
+ */
+ public function getQueuedTimestamp() {
+ return isset( $this->metadata['timestamp'] )
+ ? wfTimestampOrNull( TS_UNIX, $this->metadata['timestamp'] )
+ : null;
+ }
+
/**
* Whether the queue should reject insertion of this job if a duplicate exists
*
$job = Job::factory( $row->job_cmd, $title,
self::extractBlob( $row->job_params ), $row->job_id );
$job->metadata['id'] = $row->job_id;
+ $job->metadata['timestamp'] = $row->job_timestamp;
break; // done
} while ( true );
strlen( $row->job_params ) ? unserialize( $row->job_params ) : false
);
$job->metadata['id'] = $row->job_id;
+ $job->metadata['timestamp'] = $row->job_timestamp;
return $job;
}
);
$title = Title::makeTitle( $item['namespace'], $item['title'] );
$job = Job::factory( $item['type'], $title, $item['params'] );
$job->metadata['uuid'] = $item['uuid'];
+ $job->metadata['timestamp'] = $item['timestamp'];
return $job;
} catch ( RedisException $e ) {
$title = Title::makeTitle( $fields['namespace'], $fields['title'] );
$job = Job::factory( $fields['type'], $title, $fields['params'] );
$job->metadata['uuid'] = $fields['uuid'];
+ $job->metadata['timestamp'] = $fields['timestamp'];
return $job;
}
$backoffDeltas = array(); // map of (type => seconds)
$wait = 'wait'; // block to read backoffs the first time
+ $stats = RequestContext::getMain()->getStats();
$jobsRun = 0;
$timeMsTotal = 0;
$flags = JobQueueGroup::USE_CACHE;
$msg = $job->toString() . " STARTING";
$this->logger->debug( $msg );
$this->debugCallback( $msg );
+ $timeToRun = false;
// Run the job...
$psection = $profiler->scopedProfileIn( __METHOD__ . '-' . $jType );
$jobStartTime = microtime( true );
try {
++$jobsRun;
+ $queuedTime = $job->getQueuedTimestamp();
+ if ( $queuedTime !== null ) {
+ $timeToRun = time() - $queuedTime;
+ }
$status = $job->run();
$error = $job->getLastError();
$this->commitMasterChanges( $job );
$timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 );
$timeMsTotal += $timeMs;
$profiler->scopedProfileOut( $psection );
+ if ( $timeToRun !== false ) {
+ // Record time to run for the job type
+ $stats->timing( "jobqueue.pickup_time.$jType", $timeToRun );
+ }
// Mark the job as done on success or when the job cannot be retried
if ( $status !== false || !$job->allowRetries() ) {