SET lock:report 1 NX PX 30000
-- generate report (sometimes takes 45 s)
DEL lock:report
If the work outlasts the TTL, another client takes the lock and this
DEL deletes their lockIf the work outlasts the TTL, another client takes the lock and this DEL deletes their lock. After 30 seconds the key expires, and a second client takes the lock. The first client then runs DEL without any check. This removes the second client's lock, so a third client can also enter. The fix is a unique token plus a compare-and-delete script. "The lock never expires if the client crashes" is wrong: the TTL does protect against crashes.