Concurrency Control Questions with Answers

35 practice questions on Concurrency Control (DBMS) with answers and step-by-step solutions. Try 10 samples below, then practise all 35 free in the AptiNest app.

Sample questions

Question 1Easy

A simple way some DBMSs handle deadlocks without building a graph is:

  1. Ignoring writes
  2. Making every lock shared
  3. Disabling transactions
  4. Lock timeouts: abort a transaction that waits too long

Answer: D. Lock timeouts: abort a transaction that waits too long

Explanation

Timeouts are cheap but may abort transactions that were merely slow, not deadlocked.

Step-by-step solution

  1. Deadlock detection usually builds a wait-for graph and looks for cycles.
  2. A simpler method sets a maximum wait time for each lock request.
  3. If a transaction waits longer, it is assumed deadlocked and aborted.

Why the other options are wrong

  • A. Ignoring writes would break correctness.
  • B. Writes need exclusive locks, so all-shared locking is impossible.
  • C. Without transactions there is no atomicity.

Tip: Timeout is simple but can give false positives; a wait-for graph is exact but costs more.

Question 2Easy

Which lock must a transaction hold before it can update a data item under lock-based protocols?

  1. Exclusive (X) lock
  2. Intention-shared (IS) lock
  3. Shared (S) lock
  4. No lock is needed

Answer: A. Exclusive (X) lock

Explanation

Writing requires an exclusive lock so that no other transaction reads or writes the item at the same time.

Step-by-step solution

  1. Updating an item is a write.
  2. Writes need an exclusive (X) lock.
  3. X ensures no other transaction reads or writes the item at the same time.

Why the other options are wrong

  • B. IS is placed on ancestors to signal reads below.
  • C. S allows reading only.
  • D. Lock-based protocols require a lock for every access.

Tip: Read needs S; write needs X.

Question 3Easy

Starvation in concurrency control means:

  1. The log runs out of space
  2. A transaction reads uncommitted data
  3. A transaction waits indefinitely while others keep getting the lock
  4. All transactions are deadlocked in a single cycle and none of them can proceed

Answer: C. A transaction waits indefinitely while others keep getting the lock

Explanation

A fair (FIFO) lock queue or aging prevents a transaction from being passed over forever.

Step-by-step solution

  1. A transaction keeps asking for a lock.
  2. Other transactions keep being granted it first.
  3. It waits indefinitely even though the system as a whole makes progress: that is starvation.

Why the other options are wrong

  • A. A full log is a storage problem.
  • B. Reading uncommitted data is a dirty read.
  • D. That describes deadlock; in starvation others still proceed.

Tip: Deadlock: everyone stuck. Starvation: one is stuck while others move.

Question 4Easy

Which SQL isolation level is the weakest and permits dirty reads?

  1. READ COMMITTED
  2. SERIALIZABLE
  3. REPEATABLE READ
  4. READ UNCOMMITTED

Answer: D. READ UNCOMMITTED

Explanation

READ UNCOMMITTED allows reading other transactions' uncommitted changes. The other levels progressively prevent more anomalies.

Step-by-step solution

  1. The four standard levels from weakest to strongest are READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ and SERIALIZABLE.
  2. Only READ UNCOMMITTED allows dirty reads.
  3. So it is the weakest.

Why the other options are wrong

  • A. READ COMMITTED blocks dirty reads.
  • B. SERIALIZABLE is the strongest.
  • C. REPEATABLE READ blocks dirty and non-repeatable reads.

Tip: UC -> C -> RR -> S: each level blocks one more anomaly.

Question 5Medium

T1 reads a row, T2 updates and commits that row, and T1 reads it again getting a different value. This anomaly is a:

  1. Lost update
  2. Phantom read
  3. Dirty read
  4. Non-repeatable read

Answer: D. Non-repeatable read

Explanation

A dirty read reads uncommitted data. A phantom is a new row appearing in a repeated range query. A non-repeatable read sees a changed value of the same row.

Step-by-step solution

  1. T1 reads the row, then T2 updates it and commits.
  2. T1 reads the same row again and sees a new value.
  3. Re-reading a row and getting a different value is a non-repeatable read.

Why the other options are wrong

  • A. A lost update is one write overwriting another.
  • B. A phantom read is new rows matching a query, not a changed row.
  • C. T2 committed, so the value T1 read was not dirty.

Tip: Same row, new value = non-repeatable; new rows = phantom.

Question 6Medium

Is the following schedule conflict serializable?

R1(A)  W2(A)  R2(B)  W1(B)
  1. No, because two transactions cannot both access item B within one schedule
  2. No, because the precedence graph has a cycle T1 -> T2 -> T1
  3. Yes, equivalent to T2 then T1
  4. Yes, equivalent to T1 then T2

Answer: B. No, because the precedence graph has a cycle T1 -> T2 -> T1

Explanation

R1(A) before W2(A) gives edge T1 -> T2. R2(B) before W1(B) gives edge T2 -> T1. The cycle means no equivalent serial order exists.

Step-by-step solution

  1. R1(A) before W2(A): edge T1 -> T2.
  2. R2(B) before W1(B): edge T2 -> T1.
  3. The graph has a cycle, so the schedule is not conflict serializable.

Why the other options are wrong

  • A. Many transactions can access the same item in a schedule.
  • C. T2 then T1 would put W2(A) before R1(A), changing what T1 reads.
  • D. T1 then T2 would put W1(B) before R2(B), changing what T2 reads.

Tip: Cycle in the precedence graph = not conflict serializable.

Question 7Medium

T1 holds an intention-exclusive (IX) lock on a table. Which lock can T2 also get on the same table?

  1. SIX
  2. X
  3. S
  4. IS or IX

Answer: D. IS or IX

Explanation

IX is compatible with IS and IX, since the actual conflicts are checked at the row level; it conflicts with S, SIX and X on the table.

Step-by-step solution

  1. IX means T1 intends to lock some rows exclusively.
  2. IS and IX are compatible with IX, since rows are checked at the finer level.
  3. S, SIX and X on the whole table conflict with IX.

Why the other options are wrong

  • A. SIX includes a table-level S, which conflicts with IX.
  • B. X on the whole table conflicts with everything.
  • C. S on the whole table would read rows T1 may be changing.

Tip: IX is compatible only with IS and IX.

Question 8Medium

In multiversion concurrency control (MVCC), why do readers not block writers?

  1. Writers are made to wait until every active reader of the item has finished
  2. Readers take exclusive locks first
  3. Readers see an older committed version while writers create new versions
  4. Readers always read uncommitted data

Answer: C. Readers see an older committed version while writers create new versions

Explanation

Each write creates a new version, so a reader can use the version valid for its snapshot without locking out the writer.

Step-by-step solution

  1. A writer creates a new version of the row.
  2. Readers keep reading the last committed version from their snapshot.
  3. They need no shared locks, so they do not block writers.

Why the other options are wrong

  • A. In MVCC, writers do not wait for readers.
  • B. Readers do not take exclusive locks.
  • D. Readers see committed data, not dirty data.

Tip: MVCC: readers don't block writers, writers don't block readers.

Question 9Hard

Why do wait-die and wound-wait restart an aborted transaction with its ORIGINAL timestamp?

  1. Because new timestamps cannot be generated during recovery
  2. So it eventually becomes the oldest and cannot starve
  3. To keep the precedence graph acyclic
  4. So that its writes become visible earlier

Answer: B. So it eventually becomes the oldest and cannot starve

Explanation

Keeping the old timestamp means the transaction gets relatively older over time, so it eventually gets priority.

Step-by-step solution

  1. Both schemes favour older transactions.
  2. A restarted transaction keeps its original timestamp.
  3. As others finish, it becomes the oldest, so it can no longer be rolled back: no starvation.

Why the other options are wrong

  • A. New timestamps can always be generated.
  • C. These schemes prevent deadlock; they do not manage precedence graphs.
  • D. Timestamps do not affect when writes become visible.

Tip: Keep the old timestamp = eventually the oldest = no starvation.

Question 10Hard

A waits-for graph contains T1 -> T2, T2 -> T3, T3 -> T4 and T4 -> T2. Which transactions are deadlocked?

  1. T1, T2, T3 and T4
  2. T2, T3 and T4
  3. None, since T1 is not in the cycle
  4. T1 and T2 only

Answer: B. T2, T3 and T4

Explanation

The cycle is T2 -> T3 -> T4 -> T2. T1 is waiting on a deadlocked transaction but is not part of the cycle; aborting a cycle member frees it.

Step-by-step solution

  1. The cycle is T2 -> T3 -> T4 -> T2.
  2. Those three are deadlocked.
  3. T1 waits for T2 but is not in the cycle; it is blocked, and will continue once the deadlock is broken.

Why the other options are wrong

  • A. T1 is waiting but is not part of the cycle.
  • C. A cycle exists among T2, T3 and T4.
  • D. T1 and T2 do not form a cycle.

Tip: Deadlocked = on the cycle.

Practise all 35 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all DBMS topics · All topics