#308 Forward deployed engineer interviews 5.8 min
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.
Read the table
Copy the code folder first. Run python run.py. For each of the three strategies, write down in your own words what the lost, flagged and retries numbers mean. You should see 340 lost for last write wins, and 160 flagged for the field merge and the version check.
A hint
Lost means a change to a different field that is missing afterwards.
Fewer rounds
In rounds.py change count=500 to count=100 in the rounds function. Predict roughly how the lost, flagged and retries numbers will change, then run python run.py. With this change last write wins loses 66, the flagged count is 34 and the retries are 100. The heading line still says 500 rounds, because that text is typed by hand. When you have finished, change count=100 back to count=500.
A hint
The version check retries once per round.
Change the random seed
In rounds.py change seed=7 to seed=1 and run python run.py. With this change last write wins loses 337 and 163 are flagged. Compare this with the 340 and 160 from before. What does that tell you about how much to trust a single number from a simulation? Then change seed=1 back to seed=7, because the next exercise needs it.
A hint
The video says seeds 1 to 10 gave a range of lost updates.
Fewer fields to edit
In rounds.py change FIELDS so it holds only phone and address. Predict whether last write wins will lose more or fewer updates, and whether more or fewer rounds are flagged. Then run python run.py. With this change last write wins loses 249 and 251 rounds are flagged. Write one sentence on why. Then put FIELDS back to phone, address and credit_limit.
A hint
With fewer fields, the two systems pick the same field more often.
These tasks are for you to try on your own machine. Nothing is checked or saved.
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.
Up next in Forward deployed engineer interviews
More in Forward deployed engineer interviews
- #302 Forward Deployed Engineer Interview: What Is Tested
- #303 The FDE Decomposition Round: Vague Ask to a Plan
- #304 Scope an AI Pilot: Metric, Baseline and Stop Rule
- #305 Retry a Flaky API Without Duplicates: Idempotency Keys
- #306 Webhooks Done Right: Signatures, Retries and Replays
- #307 Schema Drift: Map a Customer's Data and Catch Changes
Related videos
- #305 Retry a Flaky API Without Duplicates: Idempotency Keys Forward deployed engineer interviews
- #302 Forward Deployed Engineer Interview: What Is Tested Forward deployed engineer interviews
- #303 The FDE Decomposition Round: Vague Ask to a Plan Forward deployed engineer interviews
- #306 Webhooks Done Right: Signatures, Retries and Replays Forward deployed engineer interviews
