A variant of 2PL, called conservative 2PL, can also be used to prevent deadlock. Using
conservative 2PL, a transaction obtains all its locks when it begins or it waits until all the
locks are available. This protocol has the advantage that if lock contention is heavy, the
time that locks are held is reduced because transactions are never blocked and therefore
never have to wait for locks. On the other hand, if lock contention is low then locks are
held longer under this protocol. Further, the overhead for setting locks is high because all
the locks must be obtained and released all at once. Thus, if a transaction fails to obtain
one lock it must release all the current locks it has obtained and start the lock process
again. From a practical perspective, a transaction may not know at the start which locks
it may actually need and, therefore, may have to set more locks than is required. This
protocol is not used in practice.