← InterviewAdvanced
Optimistic or Pessimistic Concurrency Control?
Two users edit the same record. Would you use optimistic or pessimistic concurrency control, and how do you decide?
The scenario
A CMS lets editors open a page, edit for several minutes, and save. Occasionally one editor's changes vanish with no error. The team proposes
SELECT ... FOR UPDATE at page open.What it tests
- Whether the candidate decides from the conflict rate rather than from taste
- Whether they know the mechanics of each, including the retry path
- Whether they consider the user-facing consequence of each failure mode
Answer it out loud first. Recognising a good answer is not the same skill as producing one.