From d8a12160a21b404697f138f345d3fe2dbdd289b5 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 16 Feb 2015 14:33:44 -0800 Subject: [PATCH] Removed overzealous caching from JobQueueFederated Change-Id: Id3a80dc89e5b46d6d95180e73e753b38a476eb36 --- includes/jobqueue/JobQueueFederated.php | 55 ++----------------------- 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php index 4186204d60..40936b76a6 100644 --- a/includes/jobqueue/JobQueueFederated.php +++ b/includes/jobqueue/JobQueueFederated.php @@ -54,15 +54,9 @@ class JobQueueFederated extends JobQueue { /** @var array (partition name => JobQueue) reverse sorted by weight */ protected $partitionQueues = array(); - /** @var BagOStuff */ - protected $cache; - /** @var int Maximum number of partitions to try */ protected $maxPartitionsTry; - const CACHE_TTL_SHORT = 30; // integer; seconds to cache info without re-validating - const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is kept up to date - /** * @param array $params Possible keys: * - sectionsByWiki : A map of wiki IDs to section names. @@ -126,8 +120,6 @@ class JobQueueFederated extends JobQueue { } else { $this->partitionPushRing = new HashRing( $partitionPushMap ); } - // Aggregate cache some per-queue values if there are multiple partition queues - $this->cache = count( $partitionMap ) > 1 ? wfGetMainCache() : new EmptyBagOStuff(); } protected function supportedOrders() { @@ -144,15 +136,6 @@ class JobQueueFederated extends JobQueue { } protected function doIsEmpty() { - $key = $this->getCacheKey( 'empty' ); - - $isEmpty = $this->cache->get( $key ); - if ( $isEmpty === 'true' ) { - return true; - } elseif ( $isEmpty === 'false' ) { - return false; - } - $empty = true; $failed = 0; foreach ( $this->partitionQueues as $queue ) { @@ -165,7 +148,6 @@ class JobQueueFederated extends JobQueue { } $this->throwErrorIfAllPartitionsDown( $failed ); - $this->cache->add( $key, $empty ? 'true' : 'false', self::CACHE_TTL_LONG ); return $empty; } @@ -191,13 +173,7 @@ class JobQueueFederated extends JobQueue { * @return int */ protected function getCrossPartitionSum( $type, $method ) { - $key = $this->getCacheKey( $type ); - - $count = $this->cache->get( $key ); - if ( $count !== false ) { - return $count; - } - + $count = 0; $failed = 0; foreach ( $this->partitionQueues as $queue ) { try { @@ -209,8 +185,6 @@ class JobQueueFederated extends JobQueue { } $this->throwErrorIfAllPartitionsDown( $failed ); - $this->cache->set( $key, $count, self::CACHE_TTL_SHORT ); - return $count; } @@ -279,10 +253,7 @@ class JobQueueFederated extends JobQueue { $ok = false; MWExceptionHandler::logException( $e ); } - if ( $ok ) { - $key = $this->getCacheKey( 'empty' ); - $this->cache->set( $key, 'false', self::CACHE_TTL_LONG ); - } else { + if ( !$ok ) { if ( !$partitionRing->ejectFromLiveRing( $partition, 5 ) ) { // blacklist throw new JobQueueError( "Could not insert job(s), no partitions available." ); } @@ -301,10 +272,7 @@ class JobQueueFederated extends JobQueue { $ok = false; MWExceptionHandler::logException( $e ); } - if ( $ok ) { - $key = $this->getCacheKey( 'empty' ); - $this->cache->set( $key, 'false', self::CACHE_TTL_LONG ); - } else { + if ( !$ok ) { if ( !$partitionRing->ejectFromLiveRing( $partition, 5 ) ) { // blacklist throw new JobQueueError( "Could not insert job(s), no partitions available." ); } @@ -344,9 +312,6 @@ class JobQueueFederated extends JobQueue { } $this->throwErrorIfAllPartitionsDown( $failed ); - $key = $this->getCacheKey( 'empty' ); - $this->cache->set( $key, 'true', self::CACHE_TTL_LONG ); - return false; } @@ -440,10 +405,6 @@ class JobQueueFederated extends JobQueue { 'abandonedcount' ); - foreach ( $types as $type ) { - $this->cache->delete( $this->getCacheKey( $type ) ); - } - /** @var JobQueue $queue */ foreach ( $this->partitionQueues as $queue ) { $queue->doFlushCaches(); @@ -546,14 +507,4 @@ class JobQueueFederated extends JobQueue { $queue->setTestingPrefix( $key ); } } - - /** - * @param string $property - * @return string - */ - private function getCacheKey( $property ) { - list( $db, $prefix ) = wfSplitWikiID( $this->wiki ); - - return wfForeignMemcKey( $db, $prefix, 'jobqueue', $this->type, $property ); - } } -- 2.20.1