X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpoolcounter%2FPoolCounterRedis.php;h=d609f61427af180d4f95b305e2c5b33a909d1b8e;hb=604c316e359b409144fb98608de94cf82a35f892;hp=093fe494842c927ad2e09d883ae8135a761c1694;hpb=9392d01c4e95be3c156ad594d8a8b6aa678daa7d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/poolcounter/PoolCounterRedis.php b/includes/poolcounter/PoolCounterRedis.php index 093fe49484..d609f61427 100644 --- a/includes/poolcounter/PoolCounterRedis.php +++ b/includes/poolcounter/PoolCounterRedis.php @@ -90,7 +90,7 @@ class PoolCounterRedis extends PoolCounter { $this->keySha1 = sha1( $this->key ); $met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode - $this->lockTTL = $met ? 2*$met : 3600; + $this->lockTTL = $met ? 2 * $met : 3600; if ( self::$active === null ) { self::$active = array(); @@ -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