Don't Delete My Lock

Worker A's 30 second lease expires while it is still running, so worker B acquires the lock and starts work. A finishes moments later and releases by calling DEL on the lock key. What is the defect, and what is the standard fix?

A

A released a key it no longer owned, so release should reacquire the lock first and then delete it on the same connection

B

A erases B's lock, so release must compare the stored owner value and delete only on a match, evaluated atomically in a Lua script

C

A erases B's lock, so release must GET the key, confirm the stored value is A's own token, and then issue DEL as a separate follow-up command

D

DEL leaves the key's TTL metadata behind, so release should use UNLINK to clear the key and its expiry together in one step