Skip to content
Ameen Abozaid
Planned lessonMID-015-L07

Demo: write skew under serializable

  • Lesson 7 of 7
  • Mid-level
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

  1. Rule: at least one admin must stay active. Table admin(id, active) with two active admins.
  2. Under REPEATABLE READ, both transactions check "count of active > 1" and each deactivates a different admin; both commit and no admin remains.
  3. Repeat with SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; one commit fails with 40001.
  4. Planned mistake: run the application code without retry; the user sees an error. Fix: retry the whole transaction a limited number of times.
  5. 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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.