Advanced
Open
Pro
Why a TTL Lock Isn't Enough
A batch job service uses a Redis lock (SET job:daily-export owner NX PX 30000) so only one worker runs the daily export at a time. Worker A
acquires the lock and starts writing the export file to S3. A GC pause
stalls Worker A for 45 seconds. Worker B acquires the lock (Worker A's
lease expired) and starts its own export write to the same S3 key.
Worker A then resumes and continues writing, unaware time has passed.
- Explain exactly why the TTL alone does not prevent both workers from writing.
- Introduce fencing tokens: what has to change at the lock service and at the storage layer (S3 writes) for this to be prevented?
- Does the Redlock algorithm (majority of independent Redis nodes) fix this problem? Explain the core objection.
Share this question