Deadlock in Database MCQs For Gate Exam

We’ll cover:

  • Deadlock detection
  • Deadlock prevention (wait-die, wound-wait)
  • Deadlock avoidance (wait-for graph)
  • Resource allocation graphs
  • Timeout and starvation
  • Concurrency control & locking

🧩 Deadlock in Database Systems — MCQs


Q1.

Transaction T1 holds lock on item A and requests lock on B.
Transaction T2 holds lock on B and requests lock on A.
What situation occurs?
A. Cascading abort
B. Deadlock
C. Starvation
D. Serializable schedule

Answer: B
Solution:
Circular waiting occurs:
T1 → waits for T2
T2 → waits for T1
Deadlock.


Q2.

In a system with 3 transactions {T1, T2, T3},
T1 → waits for T2
T2 → waits for T3
T3 → waits for T1.
What is this condition called?
A. Wait-for chain
B. Deadlock cycle
C. Preemption
D. Timeout

Answer: B
Solution:
Circular wait forms → deadlock exists.


Q3.

A wait-for graph helps in:
A. Deadlock prevention
B. Deadlock detection
C. Deadlock avoidance
D. Recovery

Answer: B
Solution:
A wait-for graph detects deadlocks by checking for cycles.


Q4.

In wait-die scheme, if an older transaction requests a lock held by a younger transaction:
A. Older waits
B. Older aborts
C. Younger waits
D. Younger aborts

Answer: A
Solution:
Wait-die:
Older waits, younger dies (aborts).


Q5.

In wound-wait scheme, if an older transaction requests a lock held by a younger one:
A. Older waits
B. Older aborts
C. Younger aborts
D. Both wait

Answer: C
Solution:
Wound-wait:
Older wounds (forces abort of) younger transaction.


Q6.

Which of the following is not a condition for deadlock?
A. Mutual exclusion
B. Circular wait
C. Hold and wait
D. Non-preemptive locks

Answer: D
Solution:
Four conditions:

  1. Mutual exclusion
  2. Hold & wait
  3. No preemption
  4. Circular wait
    So Non-preemptive locks ≠ condition, but no preemption is.

Q7.

If every transaction is forced to request all required resources before execution, which condition is avoided?
A. Hold & wait
B. Circular wait
C. Mutual exclusion
D. No preemption

Answer: A
Solution:
No holding during waiting → Hold & Wait eliminated → no deadlock.


Q8.

In a wait-for graph, a cycle indicates:
A. Starvation
B. Deadlock
C. Livelock
D. Inconsistent state

Answer: B
Solution:
Cycle = deadlock → transactions mutually waiting.


Q9.

Which of the following can break a deadlock?
A. Abort one transaction
B. Add a new lock
C. Increase priority
D. Wait

Answer: A
Solution:
Deadlock resolution → abort one or more transactions.


Q10.

If a transaction is aborted repeatedly due to deadlock, the situation is called:
A. Livelock
B. Starvation
C. Blocking
D. Cascading rollback

Answer: B
Solution:
Repeated aborts prevent progress → starvation.


Q11.

In wait-die scheme:
Older transaction = T1(TS=10)
Younger transaction = T2(TS=20)
If T2 requests lock held by T1:
A. T2 waits
B. T2 aborts
C. T1 aborts
D. Both wait

Answer: B
Solution:
Younger requesting older → younger dies → T2 aborts.


Q12.

If T1 (TS=5) requests a lock held by T2 (TS=9) in wound-wait:
A. T1 waits
B. T2 aborts
C. T1 aborts
D. None

Answer: B
Solution:
Older (T1) wounds younger (T2) → T2 aborts.


Q13.

Which algorithm prevents deadlock by maintaining a total order on timestamps?
A. Wait-die
B. Wound-wait
C. Both
D. None

Answer: C
Solution:
Both use timestamps to avoid circular waiting.


Q14.

A system has no deadlock but a transaction is constantly waiting for CPU or locks. This is:
A. Deadlock
B. Starvation
C. Blocking
D. None

Answer: B
Solution:
Starvation: infinite postponement despite no cycle.


Q15.

Which mechanism is lock-based prevention technique?
A. Wait-for graph
B. Timeout
C. Wait-die
D. Detection algorithm

Answer: C
Solution:
Wait-die & wound-wait = lock-based prevention.


Q16.

If timeout value is set too low in a database, it may cause:
A. Starvation
B. Deadlock
C. Faster recovery
D. Lock escalation

Answer: A
Solution:
Frequent premature aborts → starvation.


Q17.

Which of the following can lead to false deadlock detection?
A. Delayed message
B. Timestamp order
C. Strict schedule
D. Cascading abort

Answer: A
Solution:
Network latency → outdated info → false cycle.


Q18.

Which condition cannot be simultaneously violated and still guarantee serializability?
A. Circular wait
B. Hold & wait
C. No preemption
D. Mutual exclusion

Answer: D
Solution:
Mutual exclusion required for locking → cannot violate.


Q19.

Which of the following prevents deadlock before it occurs?
A. Detection
B. Prevention
C. Avoidance
D. Timeout

Answer: B
Solution:
Prevention eliminates one or more necessary conditions.


Q20.

A system with 5 resources shows a cycle in the wait-for graph involving T1, T2, T3, and T4.
Is deadlock possible?
A. Always
B. Never
C. Only if resources are single-instance
D. Only if resources are multi-instance

Answer: C
Solution:
Cycle ⇒ deadlock only for single-instance resources.


Q21.

In multi-instance resource graphs, cycle implies:
A. Deadlock guaranteed
B. Deadlock possible
C. No deadlock
D. Timeout

Answer: B
Solution:
Cycle = necessary but not sufficient condition.


Q22.

A transaction T1 waits for T2, T2 waits for T3, T3 completes.
Then:
A. Deadlock
B. Resolved
C. Starvation
D. Livelock

Answer: B
Solution:
T3 completes → cycle broken → no deadlock.


Q23.

Which condition among Coffman’s four is easiest to remove?
A. Mutual exclusion
B. Circular wait
C. Hold & wait
D. No preemption

Answer: C
Solution:
Request all resources at once → eliminates hold & wait.


Q24.

In wound-wait, younger requests older’s lock. What happens?
A. Younger waits
B. Older aborts
C. Younger aborts
D. Both abort

Answer: A
Solution:
Younger waits → avoids circular wait.


Q25.

System uses timeout method. Deadlock is prevented by:
A. Aborting transactions after time exceeds
B. Checking for cycles
C. Granting lock priority
D. Increasing timestamp

Answer: A
Solution:
Timeout aborts transactions → no indefinite wait.


Q26.

Which is deadlock avoidance technique?
A. Resource allocation graph
B. Timeout
C. Wait-die
D. Detection

Answer: A
Solution:
RAG checks safe/unsafe states → avoidance.


Q27.

If system ensures no cycle in RAG, it ensures:
A. Serializability
B. Deadlock freedom
C. Starvation
D. Cascading abort

Answer: B
Solution:
Cycle-free RAG → no deadlock.


Q28.

Deadlocks are common in:
A. Lock-based concurrency
B. Timestamp ordering
C. Validation protocol
D. None

Answer: A
Solution:
Lock-based systems → potential for circular waits.


Q29.

A deadlock-free schedule is always:
A. Serializable
B. Non-serializable
C. Strict
D. Recoverable

Answer: A
Solution:
No deadlock → all transactions complete → serializable possible.


Q30.

If T1 and T2 both hold exclusive locks and request each other’s resource, what type of lock conflict exists?
A. Shared–shared
B. Exclusive–exclusive
C. Shared–exclusive
D. None

Answer: B
Solution:
Exclusive–exclusive → mutual block → deadlock.

Deadlock in Database Systems

Q31.

Transaction T1 (TS=12) holds lock on X and requests Y.
Transaction T2 (TS=15) holds lock on Y and requests X.
Using wait-die, what happens?
A. T1 waits
B. T2 waits
C. T2 aborts
D. Deadlock occurs

Answer: A
Solution:
T1 (older) waits for T2 (younger) → T1 waits, no deadlock.


Q32.

Using wound-wait, if T1 (TS=18) requests a resource held by T2 (TS=25), what happens?
A. T1 waits
B. T2 aborts
C. T1 aborts
D. Deadlock

Answer: B
Solution:
Older wounds younger → T2 aborts.


Q33.

In wait-die, if T3 (TS=40) requests lock held by T1 (TS=10),
A. T3 waits
B. T3 aborts
C. T1 aborts
D. Both wait

Answer: B
Solution:
Younger (T3) requesting older (T1) → T3 dies (aborts).


Q34.

A system has the following edges in its wait-for graph:
T1 → T2, T2 → T3, T3 → T4, T4 → T1.
How many transactions are in deadlock?
A. 1
B. 2
C. 3
D. 4

Answer: D
Solution:
Cycle involving all → 4 transactions deadlocked.


Q35.

To break deadlock, the system can:
A. Rollback one transaction
B. Force release all locks
C. Ignore the cycle
D. Delay the request

Answer: A
Solution:
Aborting one transaction in cycle → breaks deadlock.


Q36.

Which algorithm checks for cycles periodically to detect deadlock?
A. Banker’s Algorithm
B. Wait-for Graph Algorithm
C. Timeout Algorithm
D. Timestamp Ordering

Answer: B
Solution:
WFG Algorithm → cycle detection for deadlock.


Q37.

In a system with single-instance resources, cycle in the graph implies:
A. Possible deadlock
B. Definite deadlock
C. No deadlock
D. Starvation

Answer: B
Solution:
Single instance → cycle = definite deadlock.


Q38.

Which is NOT a deadlock handling strategy?
A. Prevention
B. Avoidance
C. Detection
D. Fragmentation

Answer: D
Solution:
Deadlock handled via prevention, avoidance, detection.


Q39.

Deadlock prevention may reduce:
A. Throughput
B. Deadlock occurrence
C. Serializability
D. Concurrency

Answer: D
Solution:
Prevention restricts resource allocation → less concurrency.


Q40.

If the system aborts youngest transaction during deadlock resolution, this minimizes:
A. Data loss
B. Rollback length
C. I/O cost
D. Starvation

Answer: B
Solution:
Younger → shorter execution history → smaller rollback.


Q41.

Coffman Conditions are all necessary for deadlock except:
A. Hold and Wait
B. No Preemption
C. Resource Multiplicity
D. Circular Wait

Answer: C
Solution:
Multiplicity not part of the 4 conditions.


Q42.

If a system ensures no circular wait, how?
A. Global resource ordering
B. Timeout
C. Timestamp
D. Validation phase

Answer: A
Solution:
Global ordering of resources prevents cycles.


Q43.

Deadlock detection algorithm runs every 20 seconds in a system.
Cycle found at 40s. How long may deadlock exist undetected?
A. 0–10 sec
B. 0–19 sec
C. 20–39 sec
D. 0–20 sec

Answer: D
Solution:
Cycle may appear right after previous check → up to 20 sec delay.


Q44.

Which policy may lead to starvation in deadlock handling?
A. Timeout
B. Wound-wait
C. Wait-die
D. Both B & C

Answer: D
Solution:
Older transactions repeatedly preempt younger → possible starvation.


Q45.

Deadlock recovery using rollback requires maintaining:
A. Log file
B. Checkpoint
C. Timestamp
D. Both A & B

Answer: D
Solution:
Rollback → requires logs + checkpoint info.


Q46.

A deadlock-free system may still have:
A. Starvation
B. Cascading abort
C. Non-serializable schedule
D. Inconsistent data

Answer: A
Solution:
Deadlock-free doesn’t guarantee progress → starvation possible.


Q47.

Transaction T1 holds resource A, waits for B.
T2 holds B, waits for C.
T3 holds C, waits for A.
How many are in deadlock?
A. 1
B. 2
C. 3
D. None

Answer: C
Solution:
T1 → T2 → T3 → T1 forms a cycle of 3 → all deadlocked.


Q48.

Which of the following deadlock-handling strategies may abort transactions unnecessarily?
A. Timeout
B. Detection
C. Avoidance
D. Prevention

Answer: A
Solution:
Timeout aborts even if not truly deadlocked.


Q49.

In wound-wait, if both transactions are older than each other (TS equal), tie is broken by:
A. Random selection
B. Abort both
C. Restart system
D. Timestamp reassign

Answer: A
Solution:
Tie resolved arbitrarily to prevent indefinite delay.


Q50.

Deadlock can occur only in systems where:
A. Resources are shared
B. Locks are preemptive
C. Transactions are read-only
D. No rollback exists

Answer: A
Solution:
Exclusive/shared resource access required for deadlock.


⚙️ Part 3 — Advanced Deadlock Concepts (Q51–Q100)


Q51.

If all locks are acquired in one step, which Coffman condition is removed?
A. Hold & Wait
B. No Preemption
C. Circular Wait
D. Mutual Exclusion

Answer: A
Solution:
Acquire-all eliminates Hold & Wait.


Q52.

Which of the following ensures no deadlock but allows rollback?
A. Timeout
B. Wait-die
C. Validation
D. Timestamp ordering

Answer: B
Solution:
Wait-die prevents circular wait by ordering timestamps.


Q53.

A system has transactions T1, T2, T3 with the following waits:
T1 → T2, T2 → T3, T3 → T1.
If T3 is aborted, what happens?
A. Deadlock continues
B. Deadlock resolved
C. Starvation
D. Cascading abort

Answer: B
Solution:
Removing one node breaks cycle → resolved.


Q54.

When deadlock is detected, best transaction to abort is the one with:
A. Highest priority
B. Lowest priority
C. Smallest work done
D. Largest work done

Answer: C
Solution:
Abort transaction with least cost to restart.


Q55.

Which type of locks cannot cause deadlock?
A. Exclusive
B. Shared
C. Read-only
D. Binary

Answer: C
Solution:
Read-only → no conflicts → no deadlock.


Q56.

Which mechanism allows the system to preempt resources to avoid deadlock?
A. No preemption
B. Resource preemption
C. Timeout
D. Aging

Answer: B
Solution:
Preemption releases held resources forcibly → avoids circular wait.


Q57.

If a system can detect deadlock but not resolve it automatically, it requires:
A. Manual intervention
B. Rollback policy
C. Timestamp order
D. Wait-for graph

Answer: A
Solution:
Manual abort may be needed to recover.


Q58.

Transaction T1 (TS=4) and T2 (TS=8).
T2 holds lock; T1 requests same. Under wound-wait,
A. T1 waits
B. T2 aborts
C. T1 aborts
D. Deadlock

Answer: B
Solution:
Older T1 wounds younger T2 → T2 aborts.


Q59.

If detection is delayed, what increases?
A. Recovery time
B. CPU utilization
C. Serializability
D. Throughput

Answer: A
Solution:
Late detection → more locks held → longer rollback.


Q60.

The Banker’s Algorithm avoids deadlock by ensuring:
A. Safe state
B. Timeout
C. Timestamp
D. Priority order

Answer: A
Solution:
It simulates allocation → ensures safe state.


Q61.

A system enters an unsafe state. Does it imply deadlock?
A. Always
B. Never
C. Possibly
D. Impossible

Answer: C
Solution:
Unsafe ≠ deadlock → may lead to it if not handled.


Q62.

Which approach prevents deadlock without sacrificing concurrency much?
A. Detection
B. Timeout
C. Banker’s Algorithm
D. Wait-die

Answer: C
Solution:
Avoidance via safe state → maintains better concurrency.


Q63.

Wait-for graph with edges:
T1 → T2, T2 → T3, T3 → T1, T4 → T2.
Which transaction is not deadlocked?
A. T1
B. T2
C. T3
D. T4

Answer: D
Solution:
T4 waits but not part of cycle → not deadlocked.


Q64.

Deadlock detection complexity for n transactions is:
A. O(1)
B. O(n²)
C. O(n³)
D. O(log n)

Answer: C
Solution:
Cycle detection in directed graph → O(n³) via matrix methods.


Q65.

If timeout is too large:
A. Frequent aborts
B. Slow detection
C. Starvation
D. None

Answer: B
Solution:
Large timeout → deadlocks persist longer undetected.

Deadlock in Database System

Q66.

In a distributed database system, deadlock detection requires:
A. Local wait-for graphs only
B. Global wait-for graph
C. Timestamp comparison
D. Lock escalation

Answer: B
Solution:
Distributed deadlocks occur across sites → must combine local WFGs into a global WFG.


Q67.

Which of the following is not true about distributed deadlocks?
A. Can occur even if each site is deadlock-free
B. Requires inter-site communication
C. Cannot be prevented
D. Always requires transaction abort

Answer: D
Solution:
Sometimes deadlock can be resolved by timeout or resource preemption — abort not always required.


Q68.

A distributed system has 3 sites. Each detects deadlock every 15s, global detector runs every 30s.
Maximum undetected deadlock time?
A. 15s
B. 30s
C. 45s
D. 60s

Answer: C
Solution:
Local + global detection delay combined → up to 45s delay possible.


Q69.

In wound-wait scheme, which transaction aborts?
T1 (TS=20) requests lock held by T2 (TS=30).
A. T1
B. T2
C. Both
D. None

Answer: B
Solution:
Older T1 wounds younger T2 → T2 aborts.


Q70.

In wait-die scheme, which transaction aborts?
T3 (TS=55) requests resource held by T1 (TS=40).
A. T3
B. T1
C. Both
D. None

Answer: A
Solution:
Younger (T3) requests older (T1) → T3 dies (aborts).


Q71.

Deadlock detection frequency too high leads to:
A. Low CPU utilization
B. High detection overhead
C. Missed deadlocks
D. Less throughput

Answer: B
Solution:
Frequent detection → consumes CPU time unnecessarily.


Q72.

A transaction holding 5 resources waits for 1 more. Deadlock prevention using no hold & wait requires:
A. Release all 5 first
B. Abort immediately
C. Wait till all released
D. Random retry

Answer: A
Solution:
No hold & wait → must release all held before requesting new one.


Q73.

If a transaction is rolled back to previous checkpoint to break deadlock, which technique is used?
A. Partial rollback
B. Complete abort
C. Timeout
D. Restart

Answer: A
Solution:
Rollback to checkpoint → partial rollback method.


Q74.

Deadlock avoidance ensures system always in:
A. Safe state
B. Unsafe state
C. Circular wait
D. Mutual exclusion

Answer: A
Solution:
Avoidance uses Banker’s principle to stay in safe state.


Q75.

In resource allocation graph, a cycle means:
A. Deadlock if one instance per resource
B. Possible deadlock if multiple instances
C. No deadlock if preemptive
D. Both A & B

Answer: D
Solution:
Depends on resource multiplicity — single → definite, multiple → possible.


Q76.

Which of the following can cause a phantom deadlock?
A. Delayed message
B. Starvation
C. Timeout
D. Inconsistent timestamp

Answer: A
Solution:
Message delays can make system incorrectly believe a deadlock exists.


Q77.

If transaction T1 is rolled back repeatedly to resolve deadlocks, this leads to:
A. Starvation
B. Deadlock
C. Concurrency
D. None

Answer: A
Solution:
Repeated abort of same transaction → starvation.


Q78.

A transaction’s rollback depth increases when:
A. Checkpoint frequency decreases
B. Detection frequency increases
C. Timestamp increases
D. Lock granularity decreases

Answer: A
Solution:
Few checkpoints → rollback covers more operations.


Q79.

Which of the following best defines safe state?
A. Deadlock has not occurred yet
B. System can allocate resources to avoid deadlock
C. All processes completed
D. Circular wait removed

Answer: B
Solution:
Safe = existence of safe sequence of completion.


Q80.

A system has 3 resources R1, R2, R3 each with 1 instance.
T1 holds R1, waits R2;
T2 holds R2, waits R3;
T3 holds R3, waits R1.
System is:
A. Safe
B. Unsafe
C. Deadlocked
D. None

Answer: C
Solution:
Cycle → definite deadlock among 3.


Q81.

Which protocol prevents deadlock by ordering locks by resource name?
A. Wait-die
B. Global ordering
C. Timeout
D. Timestamp

Answer: B
Solution:
Global ordering removes circular wait possibility.


Q82.

The system detects a cycle every 50 transactions.
If 5 cycles detected, how many deadlocks possible?
A. 5
B. 10
C. 1
D. Cannot say

Answer: A
Solution:
Each cycle → one independent deadlock group.


Q83.

If two transactions compete for the same two resources alternately, deadlock probability is:
A. 0%
B. 50%
C. 100%
D. Data insufficient

Answer: C
Solution:
Both need each other’s resource → always deadlock.


Q84.

The system prevents deadlock by aborting older transactions — which scheme?
A. Wait-die
B. Wound-wait
C. Timeout
D. None

Answer: A
Solution:
In wait-die, older waits, younger aborts, not vice versa — so older never aborted → D.
But if question says “older aborts,” → none valid.


Q85.

Which of the following is most costly in terms of CPU time?
A. Prevention
B. Avoidance
C. Detection
D. Timeout

Answer: C
Solution:
Detection requires building & analyzing WFG → high overhead.


Q86.

For n transactions, number of potential wait-for edges =
A. n
B. n²
C. n(n−1)
D. 2n

Answer: C
Solution:
Each can wait for (n−1) → total n(n−1) possible edges.


Q87.

Which deadlock handling technique may terminate more than one transaction?
A. Prevention
B. Detection
C. Timeout
D. Avoidance

Answer: B
Solution:
Detection may abort multiple transactions in one cycle.


Q88.

A system avoids deadlock by ensuring no resource request leads to unsafe state. This is:
A. Banker’s Algorithm
B. Timestamp ordering
C. Two-phase locking
D. Validation-based concurrency

Answer: A
Solution:
Classic Banker’s Algorithm principle.


Q89.

If a deadlock involves 6 transactions, minimum transactions to abort to resolve it =
A. 1
B. 2
C. 3
D. 6

Answer: A
Solution:
Aborting any single transaction breaks the cycle.


Q90.

Which of the following ensures no preemption condition is violated?
A. Force release resources
B. Hold & wait
C. Timeout
D. Rollback

Answer: A
Solution:
Forcing release → preemption allowed → breaks the “no preemption” condition.


Q91.

A transaction waits for 25 sec and aborts automatically. Which mechanism?
A. Wait-die
B. Timeout
C. Deadlock detection
D. Wound-wait

Answer: B
Solution:
Abort after waiting threshold → timeout policy.


Q92.

Deadlock in 2PL can occur if:
A. Locks held till commit
B. Locks released early
C. Shared locks upgraded
D. Unlocking before growing phase

Answer: D
Solution:
Violation of growing phase (premature unlock) → potential deadlock.


Q93.

Which is an example of deadlock prevention?
A. Preallocating all resources
B. Waiting for timeout
C. Detection & rollback
D. Restarting system

Answer: A
Solution:
Preallocation removes hold & wait → prevention.


Q94.

A system has n=5 transactions, each holding one resource and waiting for one more.
If edges form a single cycle, number of deadlocks =
A. 1
B. 5
C. 10
D. n²

Answer: A
Solution:
Single cycle → one deadlock involving all 5.


Q95.

Which of the following can lead to deadlock in distributed databases?
A. Two-phase commit
B. Global timestamps
C. Lock replication
D. Concurrency control

Answer: A
Solution:
2PC can lead to deadlock if participants wait for each other’s votes.


Q96.

Which mechanism eliminates circular wait by assigning unique resource orderings?
A. Timestamp ordering
B. Resource hierarchy
C. Wait-die
D. Priority aging

Answer: B
Solution:
Global resource hierarchy → ensures no cycle.


Q97.

Which is not a valid deadlock recovery action?
A. Abort all transactions in cycle
B. Rollback one transaction
C. Ignore the cycle
D. Release some resources

Answer: C
Solution:
Ignoring cycle → deadlock persists → invalid recovery.


Q98.

In a system with 100 transactions, average detection cost per cycle = O(n³).
How many operations?
A. 10³
B. 10⁶
C. 10⁹
D. 10⁴

Answer: C
Solution:
O(100³) = 10⁶ operations → wait-for graph cycle check complexity.


Q99.

Which of the following is most efficient for deadlock handling in real-time systems?
A. Timeout
B. Detection
C. Avoidance
D. Prevention

Answer: A
Solution:
Real-time → simple timeout policy best due to low overhead.


Q100.

In wound-wait and wait-die schemes, both ensure:
A. Circular wait never forms
B. No starvation
C. Timestamp equality
D. Both abort older

Answer: A
Solution:
Both use timestamp ordering → no circular wait → no deadlock.