Why do update locks exist?
Two transactions that both take a shared lock to read a row, then both try to upgrade to exclusive to write it, wait on each other forever. An update lock says I will probably write: only one transaction can hold it, so the upgrade can never deadlock against another reader-turned-writer.
Answered in
Database Locks Explained: Shared, Exclusive, Update, Key-Range and GranularityWhat each lock mode allows, why update locks exist, how key-range locks stop phantoms, and when row, page or table locks cost you concurrency.
Read the full analysisOther questions this article answers
More system design & architecture questions
- How much spare capacity should a gateway keep?
- Why are bounded queues important for availability?
- Should a load balancer always move requests away from an unhealthy server?
- Can a circuit breaker prevent every cascading failure?
- Why does pagination improve API performance beyond just 'smaller responses'?
- Why is asynchronous logging faster than writing logs synchronously?
- When does caching actually help API performance, and when doesn't it?
- Why does payload compression trade CPU time for network time, and when is that worth it?
Every answer on Crashtech is written by the editor of the article it comes from — never auto-summarised. Browse all answers or the System Design & Architecture beat.