Test your understanding of transactions and concurrency concepts.
Which ACID property ensures “All or Nothing”?
- A) Atomicity
- B) Consistency
- C) Isolation
- D) Durability
Correct Answer: A) Atomicity
Explanation: Atomicity guarantees that either all operations in a transaction complete successfully, or none are applied. If the system crashes mid-transaction, the DBMS rolls back any partial changes.
A situation where two transactions are waiting for each other is:
- A) Serializability
- B) Deadlock
- C) Starvation
- D) Checkpoint
Correct Answer: B) Deadlock
Explanation: A deadlock occurs when Transaction A holds a lock on resource X and waits for resource Y, while Transaction B holds a lock on Y and waits for X. Neither can proceed. The DBMS detects this and aborts one transaction (the victim).
In Two-Phase Locking (2PL), once a transaction releases a lock, it:
- A) Can acquire new locks
- B) Cannot acquire any new locks
- C) Must commit immediately
- D) Can only acquire Shared locks
Correct Answer: B) Cannot acquire any new locks
Explanation: 2PL has two phases: Growing (acquire locks, no release) and Shrinking (release locks, no acquire). Once a transaction enters the shrinking phase by releasing even one lock, it cannot acquire any new locks.
Which isolation level prevents Dirty Reads but allows Phantom Reads?
- A) Read Uncommitted
- B) Read Committed
- C) Repeatable Read
- D) Serializable
Correct Answer: B) Read Committed
Explanation: Read Committed prevents Dirty Reads (reads only committed data) but allows Non-Repeatable Reads and Phantom Reads. It is the default isolation level in PostgreSQL and Oracle.
What does the Durability property guarantee?
- A) Transactions execute in isolation
- B) Committed data survives system crashes
- C) All constraints are enforced
- D) Transactions are all-or-nothing
Correct Answer: B) Committed data survives system crashes
Explanation: Durability ensures that once a transaction is committed, the changes are permanent — even if the system crashes immediately after. This is achieved through Write-Ahead Logging (WAL) — log records are written to disk before the commit is acknowledged.
A Non-Repeatable Read occurs when:
- A) A transaction reads uncommitted data
- B) A transaction reads the same row twice and gets different values
- C) A transaction’s range query returns different rows on re-execution
- D) A transaction cannot read its own writes
Correct Answer: B) A transaction reads the same row twice and gets different values
Explanation: Non-Repeatable Read happens when another transaction updates and commits a row between two reads of the same row within a single transaction. Repeatable Read isolation level prevents this.
Which technique prevents Cascading Rollbacks?
- A) Standard 2PL
- B) Strict 2PL
- C) Read Committed
- D) MVCC
Correct Answer: B) Strict 2PL
Explanation: In Standard 2PL, if a transaction releases a lock early and then aborts, other transactions that read that data must also be rolled back (cascade). Strict 2PL prevents this by holding all Exclusive Locks until the transaction commits or aborts.
In a Precedence Graph, a cycle indicates:
- A) The schedule is Conflict Serializable
- B) The schedule is NOT Conflict Serializable
- C) The schedule is View Serializable
- D) A deadlock exists
Correct Answer: B) The schedule is NOT Conflict Serializable
Explanation: A Precedence Graph with a cycle means there is a circular dependency in conflicting operations — the schedule cannot be equivalent to any serial schedule, so it is NOT Conflict Serializable.
Quick Revision
- ACID: Atomicity, Consistency, Isolation, Durability
- Transaction States: Active → Partially Committed → Committed, or Active → Failed → Aborted
- Anomalies: Dirty Read, Non-Repeatable Read, Phantom Read
- Isolation Levels: Read Uncommitted → Read Committed → Repeatable Read → Serializable
- Serializability: Check via Precedence Graph — cycle = non-serializable
- Deadlock: Circular wait — resolve by aborting a victim transaction
Premium Content
Unlock Transactions & Concurrency Quiz and all premium lessons with a subscription.
From ₹199.99/year — See plans