Merge "startup: Add unit tests and add Firefox < 4 to blacklist."
[lhc/web/wiklou.git] / includes / job / JobQueueAggregatorRedis.php
index aae800e..c6a799d 100644 (file)
@@ -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 ) {