Bird
0
0

Which of the following is the correct way to acquire locks to prevent deadlocks in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Transactions and Concurrency
Which of the following is the correct way to acquire locks to prevent deadlocks in PostgreSQL?
AAcquire locks on resources in random order.
BAcquire locks on resources in the same order in all transactions.
CNever acquire any locks in transactions.
DAcquire locks only after committing the transaction.
Step-by-Step Solution
Solution:
  1. Step 1: Understand lock acquisition order

    Acquiring locks in a consistent order prevents circular waiting.
  2. Step 2: Identify correct practice

    All transactions should acquire locks on resources in the same order to avoid deadlocks.
  3. Final Answer:

    Acquire locks on resources in the same order in all transactions. -> Option B
  4. Quick Check:

    Consistent lock order = no deadlock [OK]
Quick Trick: Always lock resources in the same order [OK]
Common Mistakes:
  • Locking resources randomly
  • Not locking resources at all
  • Locking after commit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes