
Two-Phase Locking (2PL)
Two-Phase Locking (2PL) is a method used in databases to manage how multiple transactions access shared data, ensuring consistency and preventing conflicts. It operates in two stages: 1. **Growing Phase**: A transaction can acquire locks on the data it needs but cannot release any locks. 2. **Shrinking Phase**: Once the transaction releases its first lock, it can no longer acquire new locks. This approach helps avoid issues like lost updates or dirty reads, ensuring that transactions are completed without interfering with each other, thus maintaining the integrity of the database.