redis-semaphore icon indicating copy to clipboard operation
redis-semaphore copied to clipboard

Ensure that the semaphore keeps working when app after lpop of available key

Open bliof opened this issue 4 years ago • 0 comments

Problem

You can kill the app in def lock just after the lpop of the available_key

When that happens the semaphore is gone forever. To fix it you have to manually delete the exists key.

Expirations also don't help as for some reason the exists key get -1 as a ttl

Solution

The fix is to recreate the keys in redis if there isn't an AVAILABLE or GRABBED key

Related

https://stackoverflow.com/questions/60269868/redis-semaphore-locks-cant-be-released/

ps. I have never used the gem

bliof avatar Mar 08 '20 13:03 bliof