Transactions and Concurrency Control

GATE CS previous year questions · 6 questions

GATE CS 2025 Set 1 | Question 15

MCQ · 1 mark · −0.33

A schedule of three database transactions \(T_1\), \(T_2\), and \(T_3\) is shown. \(R_i(A)\) and \(W_i(A)\) denote read and write of data item \(A\) by transaction \(T_i, i = 1,2,3\). The transaction \(T_1\) aborts at the end. Which other transaction(s) will be required to be rolled back?

\(R_1(X)\) \(W_1(Y)\) \(R_2(X)\) \(R_2(Y)\) \(R_3(Y)\) \(\mathit{ABORT}(T_1)\)

Options for GATE CS 2025 Set 1 | Question 15

Explanation

Answer: (C)

When \(T_1\) aborts, every transaction that read a value written by \(T_1\) (a dirty read) must also be rolled back; this is a cascading rollback. \(T_1\) wrote only \(Y\). Both \(R_2(Y)\) and \(R_3(Y)\) come after \(W_1(Y)\) with no other write to \(Y\) in between, so \(T_2\) and \(T_3\) both read the uncommitted value. \(R_2(X)\) does not matter, because \(T_1\) only read \(X\).

Answer: C

GATE CS 2025 Set 2 | Question 27

MSQ · 1 mark

An audit of a banking transactions system has found that on an earlier occasion, two joint holders of account \(A\) attempted simultaneous transfers of Rs. 10000 each from account \(A\) to account \(B\). Both transactions read the same value, Rs. 11000, as the initial balance in \(A\) and were allowed to go through. \(B\) was credited Rs. 10000 twice. \(A\) was debited only once and ended up with a balance of Rs. 1000.

Which of the following properties is/are certain to have been violated by the system?

Options for GATE CS 2025 Set 2 | Question 27

Explanation

Answer: (B), (C)

Each transaction read \(A = 11000\), wrote \(A = 1000\) and added Rs. 10000 to \(B\). The second write to \(A\) overwrote the first: a lost update.

  • Isolation is violated. Run one after the other, the second transfer would have seen only Rs. 1000 in \(A\); no serial order gives the observed result.
  • Consistency is violated. A transfer must keep the total \(A + B\) unchanged, but the total grew by Rs. 10000.
  • Atomicity is not shown to fail: each transaction carried out all of its steps, and nothing was left half done.
  • Durability is not shown to fail: the committed writes all survived.

Answer: B, C

GATE CS 2025 Set 2 | Question 53

MSQ · 2 marks

Consider the database transactions T1 and T2, and data items X and Y. Which of the schedule(s) is/are conflict serializable?

Transaction T1
R1(X)
W1(Y)
R1(X)
W1(X)
COMMIT(T1)
Transaction T2
W2(X)
W2(Y)
COMMIT(T2)
Options for GATE CS 2025 Set 2 | Question 53

Explanation

Answer: (B)

Build the precedence graph. Two operations conflict when they come from different transactions, touch the same item and at least one is a write; the earlier one's transaction gets an edge to the later one's. Commits add no edges.

  • (A) R1(X) before W2(X) gives T1 → T2, but W2(X) before the second R1(X) gives T2 → T1. Cycle.
  • (B) W2(X) comes before both R1(X) operations and W1(X), and W2(Y) comes before W1(Y). Every edge is T2 → T1, so the graph is acyclic and the schedule is equivalent to the serial order T2, T1.
  • (C) W1(Y) before W2(Y) gives T1 → T2, while W2(X) before the second R1(X) gives T2 → T1. Cycle.
  • (D) W2(X) before R1(X) gives T2 → T1, while W1(Y) before W2(Y) gives T1 → T2. Cycle.

Answer: B

GATE CS 2024 Set 1 | Question 46

MSQ · 2 marks

Consider the following read-write schedule \(S\) over three transactions \(T_{1}\), \(T_{2}\), and \(T_{3}\), where the subscripts in the schedule indicate transaction IDs:

\(S\colon r_{1}(z);\) \(w_{1}(z);\) \(r_{2}(x);\) \(r_{3}(y);\) \(w_{3}(y);\) \(r_{2}(y);\) \(w_{2}(x);\) \(w_{2}(y);\)

Which of the following transaction schedules is/are conflict equivalent to \(S\) ?

Options for GATE CS 2024 Set 1 | Question 46

Explanation

Answer: (B), (C), (D)

Two operations conflict when they come from different transactions, use the same item and at least one of them is a write.

  • \(z\) is used only by \(T_{1}\) and \(x\) only by \(T_{2}\), so they cause no conflicts.
  • On \(y\), both \(r_{3}(y)\) and \(w_{3}(y)\) come before \(r_{2}(y)\) and \(w_{2}(y)\). The conflicting pairs \(r_{3}(y)\)–\(w_{2}(y)\), \(w_{3}(y)\)–\(r_{2}(y)\) and \(w_{3}(y)\)–\(w_{2}(y)\) all order \(T_{3}\) before \(T_{2}\).

The precedence graph has the single edge \(T_{3} \to T_{2}\), and \(T_{1}\) is free. A serial schedule is conflict equivalent to \(S\) exactly when \(T_{3}\) comes before \(T_{2}\): \(T_{1}T_{3}T_{2}\), \(T_{3}T_{2}T_{1}\) and \(T_{3}T_{1}T_{2}\). Option A puts \(T_{2}\) first.

Answer: B, C, D

GATE CS 2024 Set 2 | Question 19

MCQ · 1 mark · −0.33

Once the DBMS informs the user that a transaction has been successfully completed, its effect should persist even if the system crashes before all its changes are reflected on disk. This property is called

Options for GATE CS 2024 Set 2 | Question 19

Explanation

Answer: (A)

This is durability, the D in ACID: once a transaction has committed, its changes must survive any later failure. The DBMS ensures it by forcing the transaction's log records to stable storage before it reports the commit, so after a crash the recovery manager can redo committed changes that had not yet reached the data pages on disk.

  • Atomicity is all-or-nothing execution: a transaction's changes are applied completely or not at all.
  • Consistency means a transaction takes the database from one valid state to another.
  • Isolation means concurrent transactions do not see each other's intermediate results.

Answer: A

GATE CS 2024 Set 2 | Question 27

MSQ · 1 mark

Which of the following statements about the Two Phase Locking (2PL) protocol is/are TRUE?

Options for GATE CS 2024 Set 2 | Question 27

Explanation

Answer: (A), (C), (D)

Under 2PL each transaction has a growing phase, in which it may only acquire locks, followed by a shrinking phase, in which it may only release them.

  • A is true. Every schedule that 2PL allows is conflict serializable, equivalent to running the transactions one after another in the order of their lock points.
  • B is false. Releasing a lock right after each operation and then locking the next item mixes the two phases, which is exactly what 2PL forbids.
  • C is true. This is the shrinking phase: after the first release, no new lock may be taken.
  • D is true. If T1 holds a lock on X and waits for Y while T2 holds Y and waits for X, both wait forever; basic 2PL does nothing to prevent this.

Answer: A, C, D