madelson / DistributedLock

A .NET library for distributed synchronization
MIT License
1.75k stars 182 forks source link

What happens if a process dies while it owns an DistributedLock.Redis? #128

Closed MaticDiba closed 2 years ago

MaticDiba commented 2 years ago

This question is related to: https://github.com/madelson/DistributedLock/issues/26

I understand that there is a mechanism for Sql lock. But what about Redis?

madelson commented 2 years ago

@MaticDiba see https://github.com/madelson/DistributedLock/blob/master/docs/Other%20topics.md#handle-abandonment

Support for releasing locks after a crash is standard across all backing technologies.

In the Redis case holding the lock is based on a timeout which the locking library renews as necessary. If the process crashes the timeout will no longer renew and will ultimately expire, allowing the system to recover.