Databases · Senior · Question 15 of 75
Why is a distributed lock in Redis (e.g. Redlock) not enough on its own to protect data correctness?
- 1Redis locks only work on one CPU core
- ✓Correct answer: A client can pause (GC, network) past the lock's expiry and still write; protecting writes needs fencing tokens checked by the storage
- 3Redis can't store keys with expiration
Explanation
Locks with timeouts are fine for efficiency (avoiding duplicate work). For correctness, the resource must reject writes with an older token, or use database transactions and constraints.