PrepCity

Pessimistic locking

Open the lab

By the last page, this is the design you will have built. Drag it, or Show all, to see every part.

Lesson · 8 pages · about 5 min

Pessimistic locking

A transaction locks the row before it checks it, so a competing writer waits; locking rows in opposite orders can deadlock, and the database breaks the cycle.

Words you’ll learn

  • Worker
  • FOR UPDATE
  • Row
  • Commit
  • Rollback
  • Deadlock
  • SKU
  • lock_timeout
  • Millisecond
  • Request

Page by page