From: Aaron Schulz Date: Thu, 14 Mar 2013 20:39:46 +0000 (-0700) Subject: Avoid duplicated effort in JobQueueAggregatorRedis::doGetAllReadyWikiQueues(). X-Git-Tag: 1.31.0-rc.0~20127^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=c10bd75c2abd055934c1b282e4af8f7cc466a389;p=lhc%2Fweb%2Fwiklou.git Avoid duplicated effort in JobQueueAggregatorRedis::doGetAllReadyWikiQueues(). Change-Id: I76bfc23ecf94c974a9eefc7d430b26d70187409e --- 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 ) {