Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/53806


Change subject: Avoid duplicated effort in 
JobQueueAggregatorRedis::doGetAllReadyWikiQueues().
......................................................................

Avoid duplicated effort in JobQueueAggregatorRedis::doGetAllReadyWikiQueues().

Change-Id: I76bfc23ecf94c974a9eefc7d430b26d70187409e
---
M includes/job/JobQueueAggregatorRedis.php
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/06/53806/1

diff --git a/includes/job/JobQueueAggregatorRedis.php 
b/includes/job/JobQueueAggregatorRedis.php
index 74e9171..312fda1 100644
--- a/includes/job/JobQueueAggregatorRedis.php
+++ b/includes/job/JobQueueAggregatorRedis.php
@@ -100,8 +100,18 @@
                                        $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 ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/53806
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I76bfc23ecf94c974a9eefc7d430b26d70187409e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to