Scenario:
we have a K8s (AKS) cluster with a Deployment including 3 replicas running a .NET container. The replicas use Redis lock to access a shared resource. If one replica dies while holding the lock, the lock is not released, so the other replicas need to wait until the lock expires before being able to proceed. To reduce this delay, we could decrease the lock expiration timeout, but if the lock expires too early, while a holder is still working on the shared resource, we get a race condition. Other solutions are possible (like renewing a lock lease etc.) non seems enough robust.
Is there a way to receive an event from the k8s engine when a pod dies?
The remaining live replicas would then remove the lock and go on with their work. No expiration issues (the lock wold be created persistent, without expitation)