From 340220080eb8a21744686b6397d0a6a2115c9742 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 2 Apr 2014 17:25:14 -0700 Subject: [PATCH] Added per-wiki queue stats information Change-Id: I25f42408c9a7a368aa99f4ceb04214f188a74be6 --- includes/jobqueue/JobQueue.php | 8 ++++++-- includes/jobqueue/JobQueueDB.php | 17 ++++++++++------- includes/jobqueue/JobQueueRedis.php | 10 +++++----- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php index a537861f43..2d7103c58f 100644 --- a/includes/jobqueue/JobQueue.php +++ b/includes/jobqueue/JobQueue.php @@ -376,7 +376,7 @@ abstract class JobQueue { // Flag this job as an old duplicate based on its "root" job... try { if ( $job && $this->isRootJobOldDuplicate( $job ) ) { - JobQueue::incrStats( 'job-pop-duplicate', $this->type ); + JobQueue::incrStats( 'job-pop-duplicate', $this->type, 1, $this->wiki ); $job = DuplicateJob::newFromJob( $job ); // convert to a no-op } } catch ( MWException $e ) { @@ -715,11 +715,15 @@ abstract class JobQueue { * @param string $key Event type * @param string $type Job type * @param int $delta + * @param string $wiki Wiki ID (added in 1.23) * @since 1.22 */ - public static function incrStats( $key, $type, $delta = 1 ) { + public static function incrStats( $key, $type, $delta = 1, $wiki = null ) { wfIncrStats( $key, $delta ); wfIncrStats( "{$key}-{$type}", $delta ); + if ( $wiki !== null ) { + wfIncrStats( "{$key}-{$type}-{$wiki}", $delta ); + } } /** diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index e83c26d58f..5f1ca14eff 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -258,11 +258,12 @@ class JobQueueDB extends JobQueue { foreach ( array_chunk( $rows, 50 ) as $rowBatch ) { $dbw->insert( 'job', $rowBatch, $method ); } - JobQueue::incrStats( 'job-insert', $this->type, count( $rows ) ); + JobQueue::incrStats( 'job-insert', $this->type, count( $rows ), $this->wiki ); JobQueue::incrStats( 'job-insert-duplicate', $this->type, - count( $rowSet ) + count( $rowList ) - count( $rows ) + count( $rowSet ) + count( $rowList ) - count( $rows ), + $this->wiki ); } catch ( DBError $e ) { if ( $flags & self::QOS_ATOMIC ) { @@ -313,7 +314,7 @@ class JobQueueDB extends JobQueue { $this->cache->set( $this->getCacheKey( 'empty' ), 'true', self::CACHE_TTL_LONG ); break; // nothing to do } - JobQueue::incrStats( 'job-pop', $this->type ); + JobQueue::incrStats( 'job-pop', $this->type, 1, $this->wiki ); // Get the job object from the row... $title = Title::makeTitleSafe( $row->job_namespace, $row->job_title ); if ( !$title ) { @@ -684,8 +685,9 @@ class JobQueueDB extends JobQueue { 'job_id' => $ids ), __METHOD__ ); - $count += $dbw->affectedRows(); - JobQueue::incrStats( 'job-recycle', $this->type, $dbw->affectedRows() ); + $affected = $dbw->affectedRows(); + $count += $affected; + JobQueue::incrStats( 'job-recycle', $this->type, $affected, $this->wiki ); $this->cache->set( $this->getCacheKey( 'empty' ), 'false', self::CACHE_TTL_LONG ); } } @@ -710,8 +712,9 @@ class JobQueueDB extends JobQueue { ); if ( count( $ids ) ) { $dbw->delete( 'job', array( 'job_id' => $ids ), __METHOD__ ); - $count += $dbw->affectedRows(); - JobQueue::incrStats( 'job-abandon', $this->type, $dbw->affectedRows() ); + $affected = $dbw->affectedRows(); + $count += $affected; + JobQueue::incrStats( 'job-abandon', $this->type, $affected, $this->wiki ); } $dbw->unlock( "jobqueue-recycle-{$this->type}", __METHOD__ ); diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php index c785cb2130..135a61d314 100644 --- a/includes/jobqueue/JobQueueRedis.php +++ b/includes/jobqueue/JobQueueRedis.php @@ -237,9 +237,9 @@ class JobQueueRedis extends JobQueue { return false; } - JobQueue::incrStats( 'job-insert', $this->type, count( $items ) ); + JobQueue::incrStats( 'job-insert', $this->type, count( $items ), $this->wiki ); JobQueue::incrStats( 'job-insert-duplicate', $this->type, - count( $items ) - $failed - $pushed ); + count( $items ) - $failed - $pushed, $this->wiki ); } catch ( RedisException $e ) { $this->throwRedisException( $conn, $e ); } @@ -331,7 +331,7 @@ LUA; break; // no jobs; nothing to do } - JobQueue::incrStats( 'job-pop', $this->type ); + JobQueue::incrStats( 'job-pop', $this->type, 1, $this->wiki ); $item = $this->unserialize( $blob ); if ( $item === false ) { wfDebugLog( 'JobQueueRedis', "Could not unserialize {$this->type} job." ); @@ -715,8 +715,8 @@ LUA; if ( $res ) { list( $released, $abandoned, $pruned, $undelayed ) = $res; $count += $released + $pruned + $undelayed; - JobQueue::incrStats( 'job-recycle', $this->type, $released ); - JobQueue::incrStats( 'job-abandon', $this->type, $abandoned ); + JobQueue::incrStats( 'job-recycle', $this->type, $released, $this->wiki ); + JobQueue::incrStats( 'job-abandon', $this->type, $abandoned, $this->wiki ); } } catch ( RedisException $e ) { $this->throwRedisException( $conn, $e ); -- 2.20.1