From b05258ae39d98dad260ab35d869ae5da6e3487d6 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 3 Dec 2012 16:21:17 -0800 Subject: [PATCH] [JobQueue] Pushed stats down to job queue subclasses. * This better handles the case where exceptions or de-duplication happen. Change-Id: I58cfa98e9d837d177fdf27ab35c68887e203270d --- includes/job/JobQueue.php | 6 ------ includes/job/JobQueueDB.php | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index e88441d94d..f7ca935dd7 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -127,9 +127,6 @@ abstract class JobQueue { } wfProfileIn( __METHOD__ ); $ok = $this->doBatchPush( $jobs, $flags ); - if ( $ok ) { - wfIncrStats( 'job-insert', count( $jobs ) ); - } wfProfileOut( __METHOD__ ); return $ok; } @@ -148,9 +145,6 @@ abstract class JobQueue { final public function pop() { wfProfileIn( __METHOD__ ); $job = $this->doPop(); - if ( $job ) { - wfIncrStats( 'job-pop' ); - } wfProfileOut( __METHOD__ ); return $job; } diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index 3e057eb16e..02f07841cd 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -110,6 +110,7 @@ class JobQueueDB extends JobQueue { foreach ( array_chunk( $rows, 50 ) as $rowBatch ) { $dbw->insert( 'job', $rowBatch, __METHOD__ ); } + wfIncrStats( 'job-insert', count( $rows ) ); } catch ( DBError $e ) { if ( $atomic ) { $dbw->rollback( __METHOD__ ); @@ -164,11 +165,11 @@ class JobQueueDB extends JobQueue { $wgMemc->set( $this->getEmptinessCacheKey(), 'true', self::CACHE_TTL ); break; // nothing to do } + wfIncrStats( 'job-pop' ); // Get the job object from the row... $title = Title::makeTitleSafe( $row->job_namespace, $row->job_title ); if ( !$title ) { $dbw->delete( 'job', array( 'job_id' => $row->job_id ), __METHOD__ ); - wfIncrStats( 'job-pop' ); wfDebugLog( 'JobQueueDB', "Row has invalid title '{$row->job_title}'." ); continue; // try again } -- 2.20.1