From 3e92b5471d224c4df0e274ffffce003ca3018f1d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 7 Oct 2013 19:30:10 -0700 Subject: [PATCH] Made root job de-duplication work without cache setup bug: 55454 Change-Id: I9fbc1e34b4b771a16e567a1a16e2720af4379188 --- includes/job/JobQueue.php | 15 ++++++++------- includes/job/JobQueueDB.php | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index 81e7b7340e..10f2c971c4 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -36,6 +36,9 @@ abstract class JobQueue { protected $maxTries; // integer; maximum number of times to try a job protected $checkDelay; // boolean; allow delayed jobs + /** @var BagOStuff */ + protected $dupCache; + const QOS_ATOMIC = 1; // integer; "all-or-nothing" job insertions const QoS_Atomic = 1; // integer; "all-or-nothing" job insertions (b/c) @@ -61,6 +64,7 @@ abstract class JobQueue { if ( $this->checkDelay && !$this->supportsDelayedJobs() ) { throw new MWException( __CLASS__ . " does not support delayed jobs." ); } + $this->dupCache = wfGetCache( CACHE_ANYTHING ); } /** @@ -439,8 +443,6 @@ abstract class JobQueue { * @return bool */ protected function doDeduplicateRootJob( Job $job ) { - global $wgMemc; - if ( !$job->hasRootJobParams() ) { throw new MWException( "Cannot register root job; missing parameters." ); } @@ -452,13 +454,13 @@ abstract class JobQueue { // deferred till "transaction idle", do the same here, so that the ordering is // maintained. Having only the de-duplication registration succeed would cause // jobs to become no-ops without any actual jobs that made them redundant. - $timestamp = $wgMemc->get( $key ); // current last timestamp of this job + $timestamp = $this->dupCache->get( $key ); // current last timestamp of this job if ( $timestamp && $timestamp >= $params['rootJobTimestamp'] ) { return true; // a newer version of this root job was enqueued } // Update the timestamp of the last root job started at the location... - return $wgMemc->set( $key, $params['rootJobTimestamp'], JobQueueDB::ROOTJOB_TTL ); + return $this->dupCache->set( $key, $params['rootJobTimestamp'], JobQueueDB::ROOTJOB_TTL ); } /** @@ -484,15 +486,14 @@ abstract class JobQueue { * @return bool */ protected function doIsRootJobOldDuplicate( Job $job ) { - global $wgMemc; - if ( !$job->hasRootJobParams() ) { return false; // job has no de-deplication info } $params = $job->getRootJobParams(); + $key = $this->getRootJobCacheKey( $params['rootJobSignature'] ); // Get the last time this root job was enqueued - $timestamp = $wgMemc->get( $this->getRootJobCacheKey( $params['rootJobSignature'] ) ); + $timestamp = $this->dupCache->get( $key ); // Check if a new root job was started at the location after this one's... return ( $timestamp && $timestamp > $params['rootJobTimestamp'] ); diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index af21bc16d1..7840f14354 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -519,7 +519,7 @@ class JobQueueDB extends JobQueue { // maintained. Having only the de-duplication registration succeed would cause // jobs to become no-ops without any actual jobs that made them redundant. list( $dbw, $scope ) = $this->getMasterDB(); - $cache = $this->cache; + $cache = $this->dupCache; $dbw->onTransactionIdle( function() use ( $cache, $params, $key, $scope ) { $timestamp = $cache->get( $key ); // current last timestamp of this job if ( $timestamp && $timestamp >= $params['rootJobTimestamp'] ) { -- 2.20.1