Re: Deadlocks and transactions

Поиск
Список
Период
Сортировка
Искать
От
David G. Johnston
Тема
Re: Deadlocks and transactions
Дата
Msg-id
CAKFQuwb3ZUnXhrdsm556tGZpEEL+J=cOqj+1MDh+VZb9fazrNA@mail.gmail.com
Ответ на
Deadlocks and transactions (JORGE MALDONADO)
Список
Дерево обсуждения
Deadlocks and transactions JORGE MALDONADO <jorgemal1960@gmail.com>
Re: Deadlocks and transactions "David G. Johnston" <david.g.johnston@gmail.com>
Re: Deadlocks and transactions Lætitia Avrot <laetitia.avrot@gmail.com>
Re: Deadlocks and transactions JORGE MALDONADO <jorgemal1960@gmail.com>
Re: Deadlocks and transactions "David G. Johnston" <david.g.johnston@gmail.com>
Re: Deadlocks and transactions David Rowley <david.rowley@2ndquadrant.com>
On Mon, Mar 19, 2018 at 2:46 PM, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
I have a process that inserts a record in one table and, after that, a record in another table is updated. Because there are 2 DB operations, I decided to perform both of them in a transaction. 

Can a deadlock take place even if transactions are used?

Its impossible to deadlock without transactions​.

Simplistically, a deadlock happens when there are two processes - one holds lock A and wants lock B while the other wants lock A while holding lock B.

Your choice to use a transaction here is good but you will have at least some risk of deadlock with others parts of the system.  Other processes running this same exact code, however, should not pose a risk since the locking order would be consistent.

David J.

В списке pgsql-novice по дате отправления
От: JORGE MALDONADO
Дата:
Сообщение: Deadlocks and transactions
От: Lætitia Avrot
Дата:
Сообщение: Re: Deadlocks and transactions
FAQ