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

Strict 2 phase locking

This locking technique satisfies the basic 2 phase locking but holds all the exclusive locks until the transaction is committed or aborted during the execution.

Some silent features of strict two-phase locking

  1. It ensures the transaction should be recoverable and cascadeless.
  2. It provides serializability.
  3. It provides the guarantee to strict schedules.
  4. It also makes a recovery very easy in case of system failure.

Let’s understand the concept of cascading rollback

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.