عرض عملي: انحراف الكتابة (write skew) تحت serializable
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
reproduce write skew and see SERIALIZABLE stop it.
تفاصيل المخطط المبدئي
خطوة بخطوة
- 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.
اختبر فهمك
Why does REPEATABLE READ allow this?
أظهر الإجابة
Each transaction writes a different row, so there is no write-write conflict.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.