5. You want to prevent deadlocks in a system where multiple transactions update two tables, Orders and Customers. Which approach is best?
hard
A. Ensure all transactions update Customers first, then Orders, and keep transactions short
B. Allow transactions to update tables in any order but increase isolation level to SERIALIZABLE
C. Use long transactions with many updates to reduce lock frequency
D. Disable locking to speed up updates
Solution
Step 1: Understand deadlock prevention principles
Accessing resources in the same order and keeping transactions short reduces deadlocks.
Step 2: Evaluate options for best practice
Ensure all transactions update Customers first, then Orders, and keep transactions short enforces consistent order and short transactions, preventing deadlocks effectively.
Step 3: Analyze other options
Allow transactions to update tables in any order but increase isolation level to SERIALIZABLE may increase deadlocks; Use long transactions with many updates to reduce lock frequency lengthens locks; Disable locking to speed up updates is unsafe and invalid.
Final Answer:
Ensure all transactions update Customers first, then Orders, and keep transactions short -> Option A
Quick Check:
Consistent order + short transactions = Deadlock prevention [OK]
Hint: Use same update order and short transactions to prevent deadlocks [OK]
Common Mistakes:
Increasing isolation level can cause more deadlocks
Long transactions hold locks longer, increasing deadlock risk
Disabling locking breaks data integrity
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.