learning-it by example

Back to the video

Two Systems Edit One Record: Lost Updates Explained

In a simulation, last write wins silently lost 340 of 1,000 edits. Two other ways lost none.

Video #308 ยท Forward deployed engineer interviews

Steps in the video

  1. 0:00 In a simulation, last write wins lost 340 of 1,000 edits
  2. 0:33 The idea
  3. 1:08 Setup
  4. 1:30 Five hundred rounds
  5. 1:51 Last write wins, and field merge
  6. 2:09 The version check
  7. 2:33 Count the lost updates
  8. 3:31 What this does not show
  9. 4:24 Mistakes to avoid
  10. 4:53 My take and next steps
  11. 5:19 Recap

Files

  • rounds.py (21 lines)
  • run.py (22 lines)
  • strategies.py (40 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

A simulation in one process with a fixed seed (seeds 1 to 10 gave 314 to 347 lost). Every round is a perfect collision, so last write wins loses one edit whenever the two fields differ. The version check's rejection and re-read are counted, not carried out. The ERP value winning a same-field conflict is my choice. Field merge is my own illustration.

Sources

Learning IT by Example.