From: Aaron Schulz Date: Tue, 8 Jul 2014 00:14:55 +0000 (-0700) Subject: Fixed acquireForMe() bug in the redis module X-Git-Tag: 1.31.0-rc.0~15063^2 X-Git-Url: http://git.cyclocoop.org/%27%2C%20%20%20quote_amp%28%24url%29%2C%20%20%20%27?a=commitdiff_plain;h=c205a99f599085bd7143e91aba99de889cc09ad3;p=lhc%2Fweb%2Fwiklou.git Fixed acquireForMe() bug in the redis module * Previously, blocked callers (due to no slots being open) would just timeout instead of getting unblocked when the slot holder released the slot. Change-Id: I67e328ca8bc1ccfb77d1ba0a753c37de3c459021 --- diff --git a/includes/poolcounter/PoolCounterRedis.php b/includes/poolcounter/PoolCounterRedis.php index 093fe49484..2b37b0b747 100644 --- a/includes/poolcounter/PoolCounterRedis.php +++ b/includes/poolcounter/PoolCounterRedis.php @@ -154,8 +154,12 @@ class PoolCounterRedis extends PoolCounter { if rSlot ~= 'w' and redis.call('exists',kSlotsNextRelease) == 1 then if 1*redis.call('zScore',kSlotsNextRelease,rSlot) ~= (rSlotTime + rExpiry) then -- Slot lock expired and was released already - elseif redis.call('lLen',kSlots) >= (1*rMaxWorkers - 1) then - -- Clear list to save space; it will re-init as needed + elseif redis.call('lLen',kSlots) >= 1*rMaxWorkers then + -- Slots somehow got out of sync; reset the list for sanity + redis.call('del',kSlots,kSlotsNextRelease) + elseif redis.call('lLen',kSlots) == (1*rMaxWorkers - 1) and redis.call('zCard',kWaiting) == 0 then + -- Slot list will be made full; clear it to save space (it re-inits as needed) + -- since nothing is waiting on being unblocked by a push to the list redis.call('del',kSlots,kSlotsNextRelease) else -- Add slot back to pool and update the "next release" time