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
Files
- rounds.py (21 lines)
- run.py (22 lines)
- strategies.py (40 lines)
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
- https://binaryigor.com/optimistic-vs-pessimistic-locking.html
- https://codemia.io/knowledge-hub/path/preventing_the_lost_update_problem_without_inconveniencing_my_consumers
- https://docs.redhat.com/en/documentation/jboss_enterprise_application_platform_common_criteria_certification/5/html/hibernate_entity_manager_reference_guide/transactions-optimistic
Learning IT by Example.