The payment timed out. Do you send it again?
transcript
Ann pays Ben fifty dollars. The app times out. Did it go through? Nobody knows. So the app sends it again. If the first one worked, Ben just got a hundred. Retrying is right. The client cannot know. So the server must make it safe.
The client invents a unique key for this payment. And sends it every time. The server looks the key up before doing anything. Seen it, same request? Return the old receipt. Move nothing. The client gets the same answer, however many times it asks.
Look up the key. Check the funds. Post two entries. Store the key. All under one lock. Outside the lock, two retries could both miss the key. The key lives on the payer's account, so the payer's lock covers it.
Same key, same request: replay it. Same key, different amount? That is a client bug. Reject it.
Retries are safe when the key and the money move together.
Full breakdown in the lecture.