Closed fho closed 2 years ago
The best defense against deadlocks is generally to avoid them by being certain that all applications using a database acquire locks on multiple objects in a consistent order. In the example above, if both transactions had updated the rows in the same order, no deadlock would have occurred. One should also ensure that the first lock acquired on an object in a transaction is the most restrictive mode that will be needed for that object. If it is not feasible to verify this in advance, then deadlocks can be handled on-the-fly by retrying transactions that abort due to deadlocks.
https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-DEADLOCKS
In our CI system a postgresql deadlock occured while recording a task run for baur. It's likely that multiple baur instances ran in parallel at the same time and where querying and or recording task runs.
happened in version: baur 2.1.0. should affect all baur versions >=2.0.0