optimistic concurrency control
A way to prevent lost updates by reading a version, preparing a change, and making the write succeed only if that version is still current.
In more detail
Nothing is locked while the client works; conflicts are detected at write time instead. In HTTP the version is the ETag and the check is If-Match, with 412 Precondition Failed when someone else got there first.
Related terms
- If-Match — The request header that makes a write conditional: the server applies it only if the resource still has the ETag the client sends.
- ETag — A response header holding an opaque tag that names one exact version of a representation, such as ETag: "1".
- 412 Precondition Failed — The HTTP status meaning a condition in the request headers, such as If-Match, was not true, so nothing was changed.
- version column — A column incremented on every update, used to detect that a row changed between read and write.
- pessimistic locking — Locking data when you read it so nobody else can change it until your transaction finishes.
- lost update — A concurrency bug where two sessions read the same value, both write a result based on it, and the later write silently erases the earlier one.
Taught in
- Caching And Conditional Requests — Modern API Architecture: REST, GraphQL & gRPC
- Worked Design One: Ticket Booking, Correctness First — Scalable System Design & Distributed Architecture
- Worked Design One: Scaling The Ticket Booking System — Scalable System Design & Distributed Architecture