According to the rules of this protocol, every transaction can be divided into two phases:
first a growing phase, in which it acquires all the locks needed but cannot release any
locks, and then a shrinking phase , in which it releases its locks but cannot acquire any
new locks. There is no requirement that all locks be obtained simultaneously. Normally,
the transaction acquires some locks, does some processing, and goes on to acquire ad-ditional locks as needed. However, it never releases any lock until it has reached a stage
where no new locks are needed. The rules are:
n A transaction must acquire a lock on an item before operating on the item. The lock may
be read or write, depending on the type of access needed.
n Once the transaction releases a lock, it can never acquire any new locks.
If upgrading of locks is allowed, upgrading can take place only during the growing
phase and may require that the transaction wait until another transaction releases a shared
lock on the item. Downgrading can take place only during the shrinking phase. We now
look at how two-phase locking is used to resolve the three problems identified in
Section 20.2.1.