Back to the 2024 paper

Unit 3: Storage and Transaction Processing

20247m

Explain two-phase locking protocol & conflict serializability. | Unit 3 – Transaction Management | Concurrency control.

Worked SolutionAI Assisted

Two-Phase Locking Protocol (2PL) & Conflict Serializability:

2PL: Transaction has growing phase (acquire locks, no unlock) and shrinking phase (release locks, no new locks). Ensures serializability but may deadlock. Strict 2PL holds exclusive locks till commit. Example: T1 locks A, B in growing, then unlocks.

Conflict Serializability: Schedule is conflict serializable if its conflict graph (precedence graph) is acyclic. Two operations conflict if they are from different transactions, on same item, at least one is write (RW, WR, WW). Graph has edge Ti -> Tj if operation of Ti conflicts before Tj.

Relationship: 2PL guarantees conflict serializability. Proof via lock points - transactions ordered by lock point (when last lock acquired). If Ti -> Tj in conflict, Ti's lock point before Tj's, no cycle. Rigorous 2PL holds.

Example: Schedule R1(A) W2(A) is not allowed under 2PL without proper lock ordering, ensures serial schedule T1->T2 or T2->T1.

Conflict serializable schedule can be transformed to serial via swapping non-conflicting operations.

Similar questions

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.