Locking
3 engineering logs on Locking. Newest first.
- Optimistic vs pessimistic locking: choose by contention, not preference
Why a version column outperforms row locks until it does not, why the crossover point is measurable rather than a matter of taste, and why retrying an optimistic failure without thinking is how you lose a customer's edit.
- Deadlocks are a lock ordering bug, and lock ordering is a design decision
Why two transactions doing the same thing in a different order will eventually stop forever, why the database picking a victim is the good outcome, and why sorting your identifiers before you touch them removes an entire class of incident.
- ADD COLUMN is not always free, and the lock queue is what takes you down
Why a metadata-only migration still took the site offline for forty minutes, how a waiting ALTER blocks every query behind it, and why lock_timeout is the setting that turns a migration into a retry.