Databases · Middle · Question 20 of 75
What is a deadlock, and what does PostgreSQL do about it?
- 1A query that never finishes; PostgreSQL waits forever
- ✓Correct answer: Two transactions each wait for a lock the other holds; PostgreSQL detects the cycle and aborts one of them with an error
- 3A table that can no longer be read
Explanation
The aborted transaction should be retried. Prevent deadlocks by locking rows in the same order everywhere and keeping transactions short.