GATE / CS ARCHIVE

GATE CSE 2012 / QUESTION 27

Conflict cycles in interleaved transactions

Database Management Systems · Transactions & Concurrency Control · Full GATE CSE 2012 paper

GATE 2012, Q27 2 marks · MCQ
Report issue

Transactions & Concurrency Control

Question 27, GATE 2012: Consider the following transactions with data items P and Q initialized to zero:
        T1 :read (P);
            read (Q);
            if P = 0 then Q := Q + 1 ;
            write (Q).
        T2 : read (Q);
            read (P);
            if Q = 0 then P := P + 1 ;
            write (P).
        Any non-serial interleaving of T1 and T2 for concurrent execution leads to
        (A) a serializable schedule
        (B) a schedule that is not conflict serializable
        (C) a conflict serializable schedule
        (D) a schedule for which a precedence graph cannot be drawn
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Conflicts arise on P between T1’s read and T2’s write, and on Q between T2’s read and T1’s write. If w1(Q) precedes r2(Q), then all of T1’s listed operations precede T2’s first operation, giving serial order T1, T2. Similarly, w2(P) before r1(P) forces serial order T2, T1. Therefore every genuinely nonserial interleaving has r1(P)<w2(P) and r2(Q)<w1(Q), giving both T1→T2 and T2→T1 in the precedence graph. The cycle proves it is not conflict serializable, B. The question’s qualification nonserial is necessary.

Check: The initial values affect the arithmetic outcomes but not the conflict edges, which depend on read/write order. Each transaction’s first read is before its last write; interleaving forces both cross-read-before-write relations, producing a directed two-cycle.

Original paper, page 6 · Answer key