From: Aaron Schulz Date: Tue, 10 Nov 2015 22:34:24 +0000 (-0800) Subject: Avoid doNotifyQueueEmpty() race conditions for Redis X-Git-Tag: 1.31.0-rc.0~8979^2~1 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=ab2e1dae28f3b15e100e814544419f6719ef06f5;p=lhc%2Fweb%2Fwiklou.git Avoid doNotifyQueueEmpty() race conditions for Redis Previously, races could cause queues to be seen as empty and ignored when they actually have jobs in them. Change-Id: I6cdf5c1fbd33c9ed7982e5d2d494974b1d7e09fd --- diff --git a/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php b/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php index 6c49646b3b..f8a004040b 100644 --- a/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php +++ b/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php @@ -59,7 +59,11 @@ class JobQueueAggregatorRedis extends JobQueueAggregator { return false; } try { - $conn->hDel( $this->getReadyQueueKey(), $this->encQueueName( $type, $wiki ) ); + // Make sure doNotifyQueueNonEmpty() takes precedence to avoid races + $conn->watch( $this->getReadyQueueKey() ); + $conn->multi() + ->hDel( $this->getReadyQueueKey(), $this->encQueueName( $type, $wiki ) ) + ->exec(); return true; } catch ( RedisException $e ) {