Two-Phase Locking
টু-ফেজ লকিং
Pessimistic concurrency — সব lock আগে নাও (growing phase), তারপর সব ফেরাও (shrinking phase); serializability-র শাস্ত্রীয় পথ।
also: 2pl, strict-two-phase-locking
Phase 1 (growing): acquire S/X locks as needed
--- lock point ---
Phase 2 (shrinking): release only; no new acquisition
- Rule: একবার lock ছাড়া শুরু করলে নতুন নেওয়া যাবে না — 2PL theorem এখানেই serializability দেয়
- Strict 2PL: সব X lock commit/until end — cascading abort এড়ায়, ব্যবহারিক মান
- Trade-off: throughput কমে (wait chain), deadlock সম্ভব; MVCC read-কে block-free করে উত্তর
Lock manager: hash table on resource id + wait queue + waiter graph — deadlock detection এই graph-এই চলে।