If a lock cannot be acquired within the time specified by deadlock_timeout, a deadlock is assumed to have occurred.
Adjusting the value of deadlock_timeout can help mitigate the occurrence of deadlocks.
Reducing the value of deadlock_timeout decrease the number of processes waiting for a lock, potentially leading to a reduction in CPU load.
Deadlocks should be avoided by devising ways to create applications, and it is desirable for the value of deadlock_timeout to be as large as possible.
With the default setting of deadlock_timeout, deadlock detection is not performed automatically.
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2025/06/02
To prevent data inconsistencies, a transaction acquires a lock on the data before updating it. When another transaction is updating data and holding a lock on it, it waits for the lock to be released. A deadlock occurs when multiple transactions are waiting for data locked by another transaction, and neither can proceed.
PostgreSQL automatically detects deadlocks and resolves them by terminating one of the transactions.
deadlock_timeout specifies the wait time before initiating deadlock detection when a transaction is blocked waiting for a lock. The default value is 1s (1 second).
This doesn't necessarily mean a deadlock has occurred; the detection process only starts after the specified timeout.
A smaller value speeds up deadlock detection but increases the chance of unnecessary detection runs.
A larger value reduces unnecessary detection but increases the delay before a real deadlock is detected.
Since deadlock detection is itself a CPU-intensive process, it should be avoided as much as possible.
In environments with frequent deadlocks, reducing deadlock_timeout might seem like a quick fix, but the best approach is to prevent deadlocks in the application and increase deadlock_timeout to avoid unnecessary CPU-intensive detection.
Therefore, the correct answer is D.