Race conditions and locks

Two changes reach the same record at the same moment. One quietly undoes the other. How do you stop it?

System design · about 5 minutes

When two changes hit the same thing at the same moment, the result depends on which finishes first, and one can quietly undo the other. That's a race condition. A lock makes the second change wait its turn.

Picture: two changes reach one member's record at once; another month goes through first, and a friend's 30 days waits at a gate