Lesson 02.7
Deadlocks & retries
A deadlock forms when transactions each hold a lock the other needs, so the database must abort one and the application must retry it.
Two kids, two toys
Ava and Ben each want to play with both the 🚗 car and the 🧸 teddy. You can only play once you're holding both.
Ava likes to grab the 🚗 first. Ben likes to grab the 🧸 first. What could go wrong?
In this lesson you'll
- 1Watch a normal playtime.
- 2Guess what happens when they grab at the same time.
- 3Find a rule so they never get stuck.