Merge "(bug 47070) check content model namespace on import."
[lhc/web/wiklou.git] / includes / job / aggregator / JobQueueAggregatorRedis.php
index 057a587..c654933 100644 (file)
@@ -104,10 +104,12 @@ class JobQueueAggregatorRedis extends JobQueueAggregator {
                                }
                        } else { // cache miss
                                // Avoid duplicated effort
+                               $rand = wfRandomString( 32 );
                                $conn->multi( Redis::MULTI );
-                               $conn->setnx( $this->getReadyQueueKey() . ":lock", 1 );
-                               $conn->expire( $this->getReadyQueueKey() . ":lock", 3600 );
+                               $conn->setex( "{$rand}:lock", 3600, 1 );
+                               $conn->renamenx( "{$rand}:lock", $this->getReadyQueueKey() . ":lock" );
                                if ( $conn->exec() !== array( true, true ) ) { // lock
+                                       $conn->delete( "{$rand}:lock" );
                                        return array(); // already in progress
                                }