django-redis-cache
django-redis-cache copied to clipboard
get_or_set(): Dogpile lock has no timeout
In the get_or_set() implementation, the dogpile lock never expires. In some edge cases it can creates some issues, here is an example:
https://github.com/sebleier/django-redis-cache/blob/918fe0b7f13a539f45e3bee240bd4d2d513d1689/redis_cache/backends/base.py#L410
- L410: value is None -> we create a dogpile lock
- L424: for some reason, the
expirenever succeeded (for instance, the client failed to get a connection in the connection pool: I believe this is what happened in my particular case)
In this particular case, the Redis cache is in a state where the dogpile lock will never get released: evert future calls to get_or_set() will return None, until someone manually releases the lock. This is not simple to debug for someone not familiar with the dogpile lock, and worst, it requires manual action to return to a "clean" state.
To avoid that I'd like to add an extra argument dogpile_timeout to the get_or_set value. I'll work on a PR to add that feature, but I'd be happy to have opinions about this idea first.
@sebleier any chance of getting this merged ?