From ab2e1dae28f3b15e100e814544419f6719ef06f5 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 10 Nov 2015 14:34:24 -0800 Subject: [PATCH] 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 --- includes/jobqueue/aggregator/JobQueueAggregatorRedis.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 ) { -- 2.20.1