BackendDatabases

Optimistic vs. Pessimistic Locking

Also written as Optimistic Locking, Pessimistic Locking, Row Locking

Two ways to stop two people overwriting each other's edits. Pessimistic locks the record while someone works on it. Optimistic lets both proceed and rejects the second save if the record changed underneath.

Think of it like

Booking the meeting room in advance, versus just turning up and sorting it out if someone else did too.

Junior or senior?

Comes up wherever money or inventory is involved.

Senior sounds like

Chose one deliberately and can explain the trade-off for their traffic pattern.

Ask them

“How did your system stop two users from overwriting each other's changes?”