All Questions
Multi Step Processes hard

You use Redis for locking a scheduled job. A worker acquires the lock, enters a 'Stop-the-World' GC pause for 1 minute, loses the lock (TTL expires), and then wakes up to write data. A new worker has already taken the lock. How do 'Fencing Tokens' prevent data corruption?

  1. A They restart the server.
  2. B They use a monotonically increasing token (e.g., epoch). The storage layer rejects any write with a token older than the current highest token seen.
  3. C They use a heartbeat to keep the lock alive forever.
  4. D They encrypt the lock key.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions