From: Aaron Schulz Date: Sun, 29 Dec 2013 21:44:33 +0000 (-0800) Subject: Fixed locking in JobQueueAggregatorRedis X-Git-Tag: 1.31.0-rc.0~17460^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=8c781f92bad810e55f6b62c06b619913cfe81d32;p=lhc%2Fweb%2Fwiklou.git Fixed locking in JobQueueAggregatorRedis * The old code would still bump the lock TTL on failure, so if processes kept trying to acquire it and the one that had it crashed, nothing would ever do anything. Change-Id: If3fe7b75364204f399fb4caf8bd39204ab51b353 --- diff --git a/includes/job/aggregator/JobQueueAggregatorRedis.php b/includes/job/aggregator/JobQueueAggregatorRedis.php index 057a5878e8..c654933c25 100644 --- a/includes/job/aggregator/JobQueueAggregatorRedis.php +++ b/includes/job/aggregator/JobQueueAggregatorRedis.php @@ -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 }