Lock Point
The Point at which the growing phase ends, i.e., when a transaction takes the final lock it needs to carry on its work. Now look at the schedule, you’ll surely understand. I have said that 2-PL ensures serializability, but there are still some drawbacks of 2-PL. Let’s glance at the drawbacks.
- Cascading Rollback is possible under 2-PL.
- Deadlocks and Starvation are possible.
Two Phase Locking Protocol
Pre-Requisite: Concurrency Control Protocol, Lock-based Protocol.
Now, recalling where we last left off, there are two types of Locks available Shared S(a) and Exclusive X(a). Implementing this lock system without any restrictions gives us the Simple Lock-based protocol (or Binary Locking), but it has its own disadvantages, they do not guarantee Serializability. Schedules may follow the preceding rules but a non-serializable schedule may result.
To guarantee serializability, we must follow some additional protocols concerning the positioning of locking and unlocking operations in every transaction. This is where the concept of Two-Phase Locking(2-PL) comes into the picture, 2-PL ensures serializability. Now, let’s dig deep!