Describe a sequence of events in which a client that correctly acquired a lock still writes data it should not have.
Sketch your own answer first, then compare it with the one below.
A strong answer
The client acquires a lease on the lock and starts its work. Before it writes, it stalls: a garbage collection pause, a swapped out page, a frozen virtual machine, or a slow disk. The lease expires at the lock service while the client is stalled. The service hands the lock to a second client, which does its work and writes.
The first client wakes up. From its point of view no time has passed. It sends the write it had prepared. Storage has no idea the lease is gone, so it accepts the write, and the first client's stale data lands on top of the second client's.
Every component did its job. The lock service expired the lease on time, the second client held a valid lock, and the first client was never told it lost anything. The fix has to be somewhere the stale write can be recognised, which is at storage.
Sources
- Martin Kleppmann (2016). How to do distributed locking.