Re: algo for canceling a deadlocked transaction - Mailing list pgsql-general

From Stephen Frost
Subject Re: algo for canceling a deadlocked transaction
Date
Msg-id 20180409135121.GJ27724@tamriel.snowman.net
Whole thread Raw
In response to algo for canceling a deadlocked transaction  (Thomas Poty <thomas.poty@gmail.com>)
Responses Re: algo for canceling a deadlocked transaction
List pgsql-general
Greetings,

* Thomas Poty (thomas.poty@gmail.com) wrote:
> My question is : In case of a deadlock between 2 transaction,  how to know
> which transaction will be canceled? Is it predictable?

The short answer is "it's whichever one detected the deadlock."  The
deadlock timeout fires after a lock has been held that long and if a
deadlock is detected then the process detecting it will be canceled.

I'd strongly recommend reviewing your application and addressing
deadlocks by changing how the application acquires locks to be
consistent and to avoid lock escalation instead of worrying about how to
predict a deadlock- a properly designed and written application
shouldn't be causing deadlocks to happen in the first place.

Thanks!

Stephen

Attachment

pgsql-general by date:

Previous
From: Thomas Poty
Date:
Subject: algo for canceling a deadlocked transaction
Next
From: Melvin Davidson
Date:
Subject: Re: Rationale for aversion to the central database?