From c10bd75c2abd055934c1b282e4af8f7cc466a389 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 14 Mar 2013 13:39:46 -0700 Subject: [PATCH] Avoid duplicated effort in JobQueueAggregatorRedis::doGetAllReadyWikiQueues(). Change-Id: I76bfc23ecf94c974a9eefc7d430b26d70187409e --- includes/job/JobQueueAggregatorRedis.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/job/JobQueueAggregatorRedis.php b/includes/job/JobQueueAggregatorRedis.php index aae800ebf0..c6a799df3f 100644 --- a/includes/job/JobQueueAggregatorRedis.php +++ b/includes/job/JobQueueAggregatorRedis.php @@ -101,8 +101,18 @@ class JobQueueAggregatorRedis extends JobQueueAggregator { $pendingDBs[$type][] = $wiki; } } else { // cache miss + // Avoid duplicated effort + $conn->multi( Redis::MULTI ); + $conn->setnx( $this->getReadyQueueKey() . ":lock", 1 ); + $conn->expire( $this->getReadyQueueKey() . ":lock", 3600 ); + if ( $conn->exec() !== array( true, true ) ) { // lock + return array(); // already in progress + } + $pendingDBs = $this->findPendingWikiQueues(); // (type => list of wikis) + $conn->delete( $this->getReadyQueueKey() . ":lock" ); // unlock + $now = time(); $map = array(); foreach ( $pendingDBs as $type => $wikis ) { -- 2.20.1