Strict 2-phase Salient features. Explain how cascading rollbacks avoided using strict two-phase locking?

What is Strict 2 phase locking?

Strict Two-Phase Locking (Strict 2PL) is a rule used in databases to keep information safe when many people are using it at the same time. It works in two main steps:

  1. Locking Phase: In this part, the system puts locks on the data that a transaction wants to use. The locks can be for reading or writing data. This step makes sure that no one else can change the data while the first transaction is still working on it.
  2. Unlocking Phase: This is when the system removes the locks, but only after the transaction is completely done, including saving any changes. This ensures that the data stays correct and safe.

The strict part means that all write locks (locks put on data that was changed) stay until the transaction is fully done and all the changes are saved. This rule helps prevent problems like data getting messed up or lost when two people try to change it at the same time.

Some silent features of strict two-phase locking

  1. Locking Phase: First, it locks the data before using it. This is like calling dibs on a game before playing.
  2. Unlocking Phase: After using the data, it unlocks it. This lets others take their turn.
  3. No Unlocking Early: It waits to unlock everything at once, at the end. This stops confusion and keeps data safe.
  4. Prevents Deadlocks: By locking and unlocking in order, it avoids deadlocks, where no one can move forward.
  5. Ensures Consistency: It makes sure data stays correct, even when many people are using the database.

Concept of Cascading Rollback

Cascading rollbacks happen when one transaction has to be undone, causing other transactions that have used the same data to also be undone. Strict Two-Phase Locking (Strict 2PL) avoids cascading rollbacks by making sure all write locks are held until a transaction is completely finished and its changes are permanently saved (committed) or undone (rolled back).


Let two transactions be T1 and T2 that are executing parallel. The transaction takes an exclusive lock on data (let’s say X) from the database, starts its operation on X, and writes the X value, but the transaction t1 is still not completed. Then transaction T2 comes into action and asks to take the X and start its execution on X, and transaction T2 is performing its remaining execution, but then the T1 failed. In this case, t1 will start its execution from the beginning again and this leads T2 to start again as T2 is dependent on the value of X generated by transaction T1. This situation is called cascading rollback.

In order to avoid this, we use a strict two-phasing locking technique where there is a restriction that a transaction holds all the exclusive locks until the transaction is committed or aborted during the execution. So until T1 release the lock on value X, the transaction T2 will wait for value X and once T1 release the lock the T2 will acquire the lock on X and performs its operation. This will make removes the possibility of cascading rollback.