Merge "[JobQueue] Pushed stats down to job queue subclasses."
authorArielGlenn <ariel@wikimedia.org>
Tue, 11 Dec 2012 08:20:51 +0000 (08:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 11 Dec 2012 08:20:51 +0000 (08:20 +0000)
includes/job/JobQueue.php
includes/job/JobQueueDB.php

index 19cecb7..65c0725 100644 (file)
@@ -128,9 +128,6 @@ abstract class JobQueue {
                }
                wfProfileIn( __METHOD__ );
                $ok = $this->doBatchPush( $jobs, $flags );
-               if ( $ok ) {
-                       wfIncrStats( 'job-insert', count( $jobs ) );
-               }
                wfProfileOut( __METHOD__ );
                return $ok;
        }
@@ -149,9 +146,6 @@ abstract class JobQueue {
        final public function pop() {
                wfProfileIn( __METHOD__ );
                $job = $this->doPop();
-               if ( $job ) {
-                       wfIncrStats( 'job-pop' );
-               }
                wfProfileOut( __METHOD__ );
                return $job;
        }
index 73ad7d9..c928682 100644 (file)
@@ -114,6 +114,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__ );
@@ -168,11 +169,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
                        }