Demo: write skew under serializable
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
reproduce write skew and see SERIALIZABLE stop it.
Draft outline details
Step by step
- Rule: at least one admin must stay active. Table
admin(id, active)with two active admins. - Under
REPEATABLE READ, both transactions check "count of active > 1" and each deactivates a different admin; both commit and no admin remains. - Repeat with
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; one commit fails with40001. - Planned mistake: run the application code without retry; the user sees an error. Fix: retry the whole transaction a limited number of times.
- Mention the alternative: lock a parent row or use a constraint.
Check your understanding
Why does REPEATABLE READ allow this?
Show answer
Each transaction writes a different row, so there is no write-write conflict.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.