Timeouts of Redis Lock

Discourse uses DistributedMutex, an implementation of Redis lock for various things. It looks that implementation of this Redis lock has timeouts, making it a “lease” instead of “lock”.

There could be possible problems like race conditions when Redis lock timeout but the work protected by Redis lock has not finished.

That’s true, but we try to design things to take significantly less time than the timeout of the lock.

If we didn’t have any kind of timeout, then we could end up in a situation where mutex is locked forever. (e.g. if an application process loses connection to redis while holding the lock)

4 Likes