This is Episode 10 of The Vibe Coder’s Guide to the Machine: computer science for a new generation.
The lost update had perfect manners. Two processes, which are programs while they run, each added 10 to a balance of 100, the stored balance ended at 110 instead of 120, and nothing complained; earlier, a price kept in a variable went on saying 80 after the stored price had been set to 60. Each write was a perfectly good number, and nobody had asked the database to wonder where it came from. So the useful question is not how to stop the second writer. It is how to make the second writer find out. B’s arithmetic was correct. What B lacked was any way to tell, at the moment it wrote, that the number it had read was no longer the number stored. Its copy carried the value and nothing else. There was no mark of when it was made and nothing a later check could compare against.
That points at what was missing. If a copy is a belief held since the moment it was made, then stopping a silent overwrite needs something the copy carries that can be checked, more than it needs a cleverer writer. The copy cannot do the checking, because it has no way of seeing the present. The place that holds the current value can, at the moment a write arrives. The database row already had that role, though no line of code said so. It was the copy allowed to decide. Every other copy, including the variable that went on saying 80, was only ever entitled to ask.



