X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJobRunner.php;h=7ce731df38508026197868a3090cb577ce847ac8;hb=6ae9367cddf8565c948f4d9458b07bb688f2ddc2;hp=2465e5aed77145e73b5656476b19ee599ca4c7b8;hpb=bfb760f9e71a7a4de34e99bf804fb6149c9e9d49;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 2465e5aed7..7ce731df38 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -109,10 +109,8 @@ class JobRunner implements LoggerAwareInterface { return $response; } - $profiler = Profiler::instance(); - // Catch huge single updates that lead to slave lag - $trxProfiler = $profiler->getTransactionProfiler(); + $trxProfiler = Profiler::instance()->getTransactionProfiler(); $trxProfiler->setLogger( LoggerFactory::getInstance( 'DBPerformance' ) ); $trxProfiler->setExpectations( $wgTrxProfilerLimits['JobRunner'], __METHOD__ ); @@ -176,7 +174,6 @@ class JobRunner implements LoggerAwareInterface { $this->debugCallback( $msg ); // Run the job... - $psection = $profiler->scopedProfileIn( __METHOD__ . '-' . $jType ); $jobStartTime = microtime( true ); try { ++$jobsPopped; @@ -197,15 +194,22 @@ class JobRunner implements LoggerAwareInterface { wfGetLBFactory()->commitAll(); $timeMs = intval( ( microtime( true ) - $jobStartTime ) * 1000 ); $timeMsTotal += $timeMs; - $profiler->scopedProfileOut( $psection ); + // Record how long jobs wait before getting popped $readyTs = $job->getReadyTimestamp(); if ( $readyTs ) { - // Record time to run for the job type $pickupDelay = $popTime - $readyTs; - $stats->timing( 'jobqueue.pickup_delay.all', $pickupDelay ); - $stats->timing( "jobqueue.pickup_delay.$jType", $pickupDelay ); + $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'] ); + $stats->timing( "jobqueue.pickup_root_age.$jType", 1000 * $age ); } + // Track the execution time for jobs + $stats->timing( "jobqueue.run.$jType", $timeMs ); // Mark the job as done on success or when the job cannot be retried if ( $status !== false || !$job->allowRetries() ) { @@ -481,7 +485,7 @@ class JobRunner implements LoggerAwareInterface { // Re-ping all masters with transactions. This throws DBError if some // connection died while waiting on locks/slaves, triggering a rollback. wfGetLBFactory()->forEachLB( function( LoadBalancer $lb ) use ( $fname ) { - $lb->forEachOpenConnection( function( DatabaseBase $conn ) use ( $fname ) { + $lb->forEachOpenConnection( function( IDatabase $conn ) use ( $fname ) { if ( $conn->writesOrCallbacksPending() ) { $conn->query( "SELECT 1", $fname ); }